diff --git a/dotfiles/lib/zsh/term_support.sh b/dotfiles/lib/zsh/term_support.sh index c056989e..23bebf34 100644 --- a/dotfiles/lib/zsh/term_support.sh +++ b/dotfiles/lib/zsh/term_support.sh @@ -33,3 +33,20 @@ function omz_termsupport_preexec { autoload -U add-zsh-hook add-zsh-hook precmd omz_termsupport_precmd add-zsh-hook preexec omz_termsupport_preexec + +function emacs_ansi_term_support { + echo -e "\033AnSiTu" "$LOGNAME" # $LOGNAME is more portable than using whoami. + echo -e "\033AnSiTc" "$(pwd)" + if [ $(uname) = "SunOS" ]; then + # The -f option does something else on SunOS and is not needed anyway. + hostname_options=""; + else + hostname_options="-f"; + fi + echo -e "\033AnSiTh" "$(hostname $hostname_options)" # Using the -f option can + # cause problems on some OSes. +} + +if environment_variable_exists INSIDE_EMACS; then + add-zsh-hook precmd emacs_ansi_term_support +fi