zsh: add mkcd()
This commit is contained in:
parent
f650ed74b5
commit
bfa78813c9
2 changed files with 13 additions and 0 deletions
|
@ -4,6 +4,7 @@ source "$ZDOTDIR/completion.zsh"
|
|||
source "$ZDOTDIR/history.zsh"
|
||||
source "$ZDOTDIR/prompt.zsh"
|
||||
source "$ZDOTDIR/vi-mode.zsh"
|
||||
source "$ZDOTDIR/functions.zsh"
|
||||
|
||||
# Prevent ctrl-s from freezing the terminal.
|
||||
stty stop undef
|
||||
|
|
12
config/zsh/functions.zsh
Normal file
12
config/zsh/functions.zsh
Normal file
|
@ -0,0 +1,12 @@
|
|||
# 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
|
||||
}
|
||||
|
Loading…
Add table
Reference in a new issue