diff options
Diffstat (limited to 'dot_config/zsh')
| -rw-r--r-- | dot_config/zsh/functions/tt | 15 | ||||
| -rw-r--r-- | dot_config/zsh/zshrc | 7 |
2 files changed, 16 insertions, 6 deletions
diff --git a/dot_config/zsh/functions/tt b/dot_config/zsh/functions/tt new file mode 100644 index 0000000..0328e71 --- /dev/null +++ b/dot_config/zsh/functions/tt @@ -0,0 +1,15 @@ +# vim: ft=zsh +typeset -gaU __tt_exit_dirs +__tt_exit() { + (( ${+__tt_exit_dirs[1]} )) && rm -r "${__tt_exit_dirs[@]}" +} +autoload -Uz add-zsh-hook +add-zsh-hook zshexit __tt_exit +tt() { + local dir=$(mktemp -d) + [ -d "$dir" ] || return 1 + cd "$dir" + __tt_exit_dirs+=("$dir") +} + +tt "$@" diff --git a/dot_config/zsh/zshrc b/dot_config/zsh/zshrc index f7d4cc2..f0c99e2 100644 --- a/dot_config/zsh/zshrc +++ b/dot_config/zsh/zshrc @@ -41,16 +41,11 @@ if [[ -x =luarocks ]] { } ## Functions +autoload -Uz tt t() { mkdir -p /tmp/t cd /tmp/t } -tt() { - local dir=$(mktemp -d) - [ -d "$dir" ] || return 1 - cd "$dir" - trap "rm -rf '$dir'" EXIT -} # you may want to: # set up jump/zoxide/etc |
