main/config/zsh/functions.zsh

28 lines
848 B
Bash

# functions.zsh — ported from fish functions (server-relevant subset)
# make dir + cd into it
mcd() { mkdir -p "$1" && cd "$1"; }
# reload zsh config
so() { source "${ZDOTDIR:-$HOME/.config/zsh}/zshrc" 2>/dev/null || source "$HOME/.zshrc"; }
# cd into ~/.config, edit/open the named file/dir (interactive)
conf() {
local base="${XDG_CONFIG_HOME:-$HOME/.config}"
cd "$base" || return
if [[ -f "$1" ]]; then
echo "Editing $1"; $EDITOR "$1"
elif [[ -d "$1" ]]; then
echo "Opening config dir $1"; cd "$1" && ls -al
else
read "confirm?Can't find $1, open in \$EDITOR? (Y/n) "
if [[ -z "$confirm" || "$confirm" =~ ^[Yy]$ ]]; then
$EDITOR "$1"
else
echo "Exiting…"
fi
fi
}
# ssh onward with a sane TERM (avoids terminfo breakage on older boxes)
ssh() { TERM=xterm command ssh "$@"; }