zsh: autoload custom functions

This commit is contained in:
Fernando Schauenburg 2023-10-07 16:47:44 +02:00
parent de3235450c
commit 410ac2d1b2
3 changed files with 17 additions and 13 deletions

View file

@ -1,12 +1,18 @@
# Set up zsh for interactive use (options, prompt, aliases, etc.)
source "$ZDOTDIR/aliases.zsh"
source "$ZDOTDIR/completion.zsh"
source "$ZDOTDIR/functions.zsh"
source "$ZDOTDIR/history.zsh"
source "$ZDOTDIR/line-editor.zsh"
source "$ZDOTDIR/man-pages.zsh"
source "$ZDOTDIR/prompt.zsh"
# Set up autoload for custom functions.
fpath=("$ZDOTDIR/functions" $fpath)
for filepath in $ZDOTDIR/functions/*; do
autoload "${filepath##*/}"
done
unset filepath
# Prevent ctrl-s from freezing the terminal.
stty stop undef

View file

@ -1,12 +0,0 @@
# Source: https://unix.stackexchange.com/a/9124
mkcd() {
case "$1" in
*/..|*/../) cd -- "$1" ;;
/*/../*) (cd "${1%/../*}/.." && mkdir -vp "./${1##*/../}") && cd -- "$1" ;;
/*) mkdir -vp "$1" && cd "$1" ;;
*/../*) (cd "./${1%/../*}/.." && mkdir -vp "./${1##*/../}") && cd "./$1";;
../*) (cd .. && mkdir -vp "${1#.}") && cd "$1" ;;
*) mkdir -vp "./$1" && cd "./$1";;
esac
}

10
config/zsh/functions/mkcd Normal file
View file

@ -0,0 +1,10 @@
# Source: https://unix.stackexchange.com/a/9124
case "$1" in
*/..|*/../) cd -- "$1" ;;
/*/../*) (cd "${1%/../*}/.." && mkdir -vp "./${1##*/../}") && cd -- "$1" ;;
/*) mkdir -vp "$1" && cd "$1" ;;
*/../*) (cd "./${1%/../*}/.." && mkdir -vp "./${1##*/../}") && cd "./$1";;
../*) (cd .. && mkdir -vp "${1#.}") && cd "$1" ;;
*) mkdir -vp "./$1" && cd "./$1";;
esac