Skip to content

Commit

Permalink
Make the zsh integration work with zsh's prompt system, and make it m…
Browse files Browse the repository at this point in the history
…ore compatible with older zsh versions

issue #61
  • Loading branch information
sedwards2009 committed Sep 25, 2017
1 parent 7c79dbd commit 46b593c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
18 changes: 13 additions & 5 deletions extensions/InjectShellIntegration/src/ScriptBuilders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,22 @@ export class ZshScriptBuilder extends ScriptBuilder {

protected _buildShellReporting(): string {
return `
if [[ ! "$PS1" =~ "${this._extratermCookieValue}" ]] ; then
export PS1=\`echo -n -e "%{\\033&${this._extratermCookieValue};3\\007%}%?%{\\000%}\${PS1}"\`
fi
autoload -Uz add-zsh-hook
extraterm_install_prompt_integration () {
local prefix
if [[ ! "$PS1" =~ "${this._extratermCookieValue}" ]] ; then
prefix=\`echo -n -e "%{\\0033&${this._extratermCookieValue};3\\0007%}%?%{\\0000%}"\`
export PS1="\${prefix}\${PS1}"
fi
}
extraterm_install_prompt_integration
add-zsh-hook precmd extraterm_install_prompt_integration
preexec () {
echo -n -e "\\033&\${${this._extratermCookieName}};2;zsh\\007"
echo -n -e "\\0033&\${${this._extratermCookieName}};2;zsh\\0007"
echo -n $1
echo -n -e "\\000"
echo -n -e "\\0000"
}
`;
}
Expand Down
19 changes: 15 additions & 4 deletions src/commands/setup_extraterm_zsh.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,30 @@
#

if [ -n "$LC_EXTRATERM_COOKIE" ]; then
autoload -Uz add-zsh-hook

echo "Setting up Extraterm support."

# Put our enhanced commands at the start of the PATH.
filedir=`dirname "${(%):-%x}"`
export PATH="$PWD/$filedir:$PATH"

# Insert our special code to communicate to Extraterm the status of the last command.
export PS1=`echo -n -e "%{\033&${LC_EXTRATERM_COOKIE};3\007%}%?%{\000%}${PS1}"`

extraterm_install_prompt_integration () {
local prefix

if [[ ! "$PS1" =~ "$LC_EXTRATERM_COOKIE" ]] ; then
prefix=`echo -n -e "%{\0033&${LC_EXTRATERM_COOKIE};3\0007%}%?%{\0000%}"`
export PS1="${prefix}${PS1}"
fi
}
extraterm_install_prompt_integration
add-zsh-hook precmd extraterm_install_prompt_integration

preexec () {
echo -n -e "\033&${LC_EXTRATERM_COOKIE};2;zsh\007"
echo -n -e "\0033&${LC_EXTRATERM_COOKIE};2;zsh\0007"
echo -n $1
echo -n -e "\000"
echo -n -e "\0000"
}

# Look for Python 3 support.
Expand Down

0 comments on commit 46b593c

Please sign in to comment.