diff --git a/config/zsh/.zshrc b/config/zsh/.zshrc index 07b7746..58c8ee2 100644 --- a/config/zsh/.zshrc +++ b/config/zsh/.zshrc @@ -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 diff --git a/config/zsh/functions.zsh b/config/zsh/functions.zsh deleted file mode 100644 index e15b6ef..0000000 --- a/config/zsh/functions.zsh +++ /dev/null @@ -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 -} - diff --git a/config/zsh/functions/mkcd b/config/zsh/functions/mkcd new file mode 100644 index 0000000..9661acf --- /dev/null +++ b/config/zsh/functions/mkcd @@ -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 +