Add helper functions for vterm

This commit is contained in:
Andreas Zweili 2022-09-02 22:53:16 +02:00
parent eb7c1914b7
commit a242afbcc3
1 changed files with 22 additions and 0 deletions

View File

@ -109,4 +109,26 @@
enable = true;
client.enable = true;
};
programs.bash = {
enable = true;
bashrcExtra = ''
vterm_printf(){
if [ -n "$TMUX" ] && ([ "\$\{TERM%%-*}" = "tmux" ] || [ "\$\{TERM%%-*}" = "screen" ] ); then
# Tell tmux to pass the escape sequences through
printf "\ePtmux;\e\e]%s\007\e\\" "$1"
elif [ "\$\{TERM%%-*}" = "screen" ]; then
# GNU screen (screen, screen-256color, screen-256color-bce)
printf "\eP\e]%s\007\e\\" "$1"
else
printf "\e]%s\e\\" "$1"
fi
}
vterm_prompt_end(){
vterm_printf "51;A$(whoami)@$(hostname):$(pwd)"
}
PS1=$PS1'\[$(vterm_prompt_end)\]'
'';
};
}