Skip to content

Instantly share code, notes, and snippets.

@vkgtaro
Last active August 29, 2015 14:08
Show Gist options
  • Select an option

  • Save vkgtaro/42e76b9af5a1efccc309 to your computer and use it in GitHub Desktop.

Select an option

Save vkgtaro/42e76b9af5a1efccc309 to your computer and use it in GitHub Desktop.
#-----------------------------------------------
# screen の下のラインに打ったコマンドを表示
#-----------------------------------------------
if [ "$TERM" = "screen" ]; then
chpwd () { echo -n "^[_`dirs`^[\\" }
preexec() {
# see [zsh-workers:13180]
# http://www.zsh.org/mla/workers/2000/msg03993.html
emulate -L zsh
local -a cmd; cmd=(${(z)2})
case $cmd[1] in
fg)
if (( $#cmd == 1 )); then
cmd=(builtin jobs -l %+)
else
cmd=(builtin jobs -l $cmd[2])
fi
;;
%*)
cmd=(builtin jobs -l $cmd[1])
;;
cd)
if (( $#cmd == 2)); then
cmd[1]=$cmd[2]
fi
;&
*)
echo -n "^[k$cmd[1]:t^[\\"
return
;;
esac
local -A jt; jt=(${(kv)jobtexts})
$cmd >>(read num rest
cmd=(${(z)${(e):-\$jt$num}})
echo -n "^[k$cmd[1]:t^[\\") 2>/dev/null
}
chpwd
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment