From 93df81a6c9d1592ccadc9282b71a9d04cf1fe5c3 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Thu, 15 Oct 2015 03:25:25 -0700 Subject: [PATCH] emacs_ansi_term_support for zsh shell --- dotfiles/lib/zsh/term_support.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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