diff --git a/functions/vim.zsh b/functions/vim.zsh index 89e0328..4726f96 100644 --- a/functions/vim.zsh +++ b/functions/vim.zsh @@ -1,12 +1,12 @@ # open vim with a scratch window that can be discarded on exit. vimscratch() { + set -x local args # if running in a pipe, use stdin (-) as arg. # -t checks if the given FD is a terminal - if [ -t 0 ] ; then - args="$@" - else - args="-" + if [ ! -t 0 ] ; then + stdin_arg="-" fi - vim -c "set buftype=nofile" "$args" + vim -c "set buftype=nofile" $@ $stdin_arg + set +x }