Skip to content

Commit

Permalink
Update the iterm2 shell integration for nightly
Browse files Browse the repository at this point in the history
  • Loading branch information
gsamokovarov committed Feb 13, 2017
1 parent 067e1e9 commit d688881
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions .config/fish/iterm2.fish
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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
Expand All @@ -75,15 +72,18 @@ 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
iterm2_prompt_end
end
end

function -v _ underscore_change
function underscore_change -v _
if [ x$_ = xfish ]
iterm2_precmd
else
Expand All @@ -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

0 comments on commit d688881

Please sign in to comment.