From 336063f13d39c122fa17ab325117b904b5ed4d82 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Thu, 18 May 2017 16:35:35 +0200 Subject: zsh: Load terminal title function from omz directly --- zsh/.config/zsh/.zshrc | 57 ++++---------------------------------------------- 1 file changed, 4 insertions(+), 53 deletions(-) (limited to 'zsh') diff --git a/zsh/.config/zsh/.zshrc b/zsh/.config/zsh/.zshrc index 1d827a27..da25b3dc 100644 --- a/zsh/.config/zsh/.zshrc +++ b/zsh/.config/zsh/.zshrc @@ -122,6 +122,9 @@ zplugin load "caarlos0/zsh-open-pr" zplugin ice blockf zplugin load "mollifier/anyframe" +zplugin snippet "https://github.com/robbyrussell/oh-my-zsh/blob/master/lib/functions.zsh" +zplugin snippet "https://github.com/robbyrussell/oh-my-zsh/blob/master/lib/termsupport.zsh" + if [[ $os -eq darwin ]] then zplugin load "unixorn/tumult.plugin.zsh" @@ -183,59 +186,7 @@ else setopt prompt_subst setopt prompt_cr PROMPT='%F{blue}%~%f${prompt_pure_username} -%(?.%F{magenta}.%F{red})>%f ' - - ## From https://github.com/robbyrussell/oh-my-zsh/blob/71deb74552d54630d99ae1db3647ebed7b3bc735/lib/termsupport.zsh - - # Keep Apple Terminal.app's current working directory updated - # Based on this answer: http://superuser.com/a/315029 - # With extra fixes to handle multibyte chars and non-UTF-8 locales - - if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then - # Emits the control sequence to notify Terminal.app of the cwd - # Identifies the directory using a file: URI scheme, including - # the host name to disambiguate local vs. remote paths. - function update_terminalapp_cwd() { - emulate -L zsh - - # Percent-encode the pathname. - # Percent-encode the pathname. - local URL_PATH='' - { - # Use LC_CTYPE=C to process text byte-by-byte. - local i ch hexch LC_CTYPE=C - for ((i = 1; i <= ${#PWD}; ++i)); do - ch="$PWD[i]" - if [[ "$ch" =~ [/._~A-Za-z0-9-] ]]; then - URL_PATH+="$ch" - else - hexch=$(printf "%02X" "'$ch") - URL_PATH+="%$hexch" - fi - done - } - [[ $? != 0 ]] && return 1 - - printf '\e]7;%s\a' "file://$HOST$URL_PATH" - } - - # Use a precmd hook instead of a chpwd hook to avoid contaminating output - precmd_functions+=(update_terminalapp_cwd) - # Run once to get initial cwd set - update_terminalapp_cwd - fi - - function set_window_title { printf '\e]2;%s\a' "$1" } - - function update_window_title { - if [[ -n "$SSH_CONNECTION" || $UID -eq 0 ]] - then - set_window_title "$USER@$HOST" - else - set_window_title "" - fi - } - precmd_functions+=(update_window_title) +%(?.%F{magenta}.%F{red})>%f ' fi if [[ -n $commands[fzf] ]] -- cgit 1.4.1