From d68888114a657343351814f7f5a7289944b4333a Mon Sep 17 00:00:00 2001 From: Genadi Samokovarov Date: Mon, 13 Feb 2017 18:55:05 +0200 Subject: [PATCH] Update the iterm2 shell integration for nightly --- .config/fish/iterm2.fish | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.config/fish/iterm2.fish b/.config/fish/iterm2.fish index e9d3acf..11950c0 100755 --- a/.config/fish/iterm2.fish +++ b/.config/fish/iterm2.fish @@ -4,7 +4,7 @@ if begin; status --is-interactive; and not functions -q -- iterm2_status; and [ end # Mark start of prompt - function iterm2_prompt_start + function iterm2_prompt_mark printf "\033]133;A\007" end @@ -25,7 +25,7 @@ if begin; status --is-interactive; and not functions -q -- iterm2_status; and [ # Gives a variable accessible in a badge by \(user.currentDirectory) # Calls to this go in iterm2_print_user_vars. function iterm2_set_user_var - printf "\033]1337;SetUserVar=%s=%s\007" "$argv[1]" (printf "%s" "$argv[2]" | base64) + printf "\033]1337;SetUserVar=%s=%s\007" "$argv[1]" (printf "%s" "$argv[2]" | base64 | tr -d "\n") end # iTerm2 inform terminal that command starts here @@ -47,24 +47,21 @@ if begin; status --is-interactive; and not functions -q -- iterm2_status; and [ functions -c fish_mode_prompt iterm2_fish_mode_prompt function fish_mode_prompt --description 'Write out the mode prompt; do not replace this. Instead, change fish_mode_prompt before sourcing .iterm2_shell_integration.fish, or modify iterm2_fish_mode_prompt instead.' set -l last_status $status + iterm2_status $last_status - iterm2_prompt_start + if not functions iterm2_fish_prompt | grep iterm2_prompt_mark > /dev/null + iterm2_prompt_mark + end sh -c "exit $last_status" iterm2_fish_mode_prompt end function fish_prompt --description 'Write out the prompt; do not replace this. Instead, change fish_prompt before sourcing .iterm2_shell_integration.fish, or modify iterm2_fish_prompt instead.' - # Remove the trailing newline from the original prompt. Storing a - # command's output to a variable loses all the newlines, causing the - # prompt's lines to get joined together. You also can't pass it to a - # shell command command. So we can only use it in something like a for - # loop. - for line in (iterm2_fish_prompt) - set -q last_line; and echo $last_line - set last_line $line - end - set -q last_line; and echo -n $last_line + # Remove the trailing newline from the original prompt. This is done + # using the string builtin from fish, but to make sure any escape codes + # are correctly interpreted, use %b for printf. + printf "%b" (string join "\n" (iterm2_fish_prompt)) iterm2_prompt_end end @@ -75,7 +72,10 @@ if begin; status --is-interactive; and not functions -q -- iterm2_status; and [ set -l last_status $status iterm2_status $last_status - iterm2_prompt_start + if not functions iterm2_fish_prompt | grep iterm2_prompt_mark > /dev/null + iterm2_prompt_mark + end + # Restore the status sh -c "exit $last_status" iterm2_fish_prompt @@ -83,7 +83,7 @@ if begin; status --is-interactive; and not functions -q -- iterm2_status; and [ end end - function -v _ underscore_change + function underscore_change -v _ if [ x$_ = xfish ] iterm2_precmd else @@ -97,6 +97,6 @@ if begin; status --is-interactive; and not functions -q -- iterm2_status; and [ end iterm2_precmd - printf "\033]1337;ShellIntegrationVersion=2;shell=fish\007" + printf "\033]1337;ShellIntegrationVersion=5;shell=fish\007" end alias imgcat=~/.iterm2/imgcat; alias it2dl=~/.iterm2/it2dl