mirror of
https://git.decapod.one/brethil/dotfiles
synced 2024-11-22 03:21:30 +01:00
zsh/tmux: add prompt marker/add copy-mode shortcuts
tmux allows moving between shell prompts when the prompt is marked with the OSC 133 escape sequence (`\033[133;A\033\\]`). This is added to the zsh prompt and `next-prompt` and `previous-prompt` are bound to `n` and `p` in tmux copy mode.
This commit is contained in:
parent
8a72eaff6f
commit
5ad7209f8f
|
@ -81,13 +81,18 @@ function __prompt_too_long(){
|
||||||
# prints a newline if less than $COLUMNS/2 characters remain to the right margin, see end of `man zshmisc`
|
# prints a newline if less than $COLUMNS/2 characters remain to the right margin, see end of `man zshmisc`
|
||||||
echo "%-$((COLUMNS/2))(l..\n)"
|
echo "%-$((COLUMNS/2))(l..\n)"
|
||||||
}
|
}
|
||||||
|
function __print_prompt_marker(){
|
||||||
|
# prints the escape sequence that tmux interprets as prompt start (see next-prompt/previous-prompt in `man tmux`)
|
||||||
|
printf '\033]133;A\033\\'
|
||||||
|
}
|
||||||
|
|
||||||
## oh-my-zsh vi-mode plugins indicators:
|
## oh-my-zsh vi-mode plugins indicators:
|
||||||
export MODE_INDICATOR="[%B%K{red}nav%k%b]" # red background
|
export MODE_INDICATOR="[%B%K{red}nav%k%b]" # red background
|
||||||
export INSERT_MODE_INDICATOR="[%B%K{28}ins%k%b]" # green background
|
export INSERT_MODE_INDICATOR="[%B%K{28}ins%k%b]" # green background
|
||||||
|
|
||||||
# put it all together
|
## put it all together
|
||||||
PROMPT='$(__virtualenv_info)'"${user_prompt}${path_prompt}${git_prompt}${job_prompt}${shlvl_prompt}$(__prompt_too_long)${prompt_with_previous_return_status}"
|
# Note: wrapping __print_prompt_marker in extra %{...%} works around an issue with zsh autosuggestions with escape sequences
|
||||||
|
# see https://github.com/zsh-users/zsh-autosuggestions/issues/570 for more information
|
||||||
# Right prompt is just return code and time
|
PROMPT='$(__virtualenv_info)'"${user_prompt}${path_prompt}${git_prompt}${job_prompt}${shlvl_prompt}$(__prompt_too_long)${prompt_with_previous_return_status}%{$(__print_prompt_marker)%} "
|
||||||
|
# right prompt indicator: return code, vi mode prompt info and current time
|
||||||
RPS1="${return_code_RPS1}"'$(vi_mode_prompt_info)[%*]'
|
RPS1="${return_code_RPS1}"'$(vi_mode_prompt_info)[%*]'
|
||||||
|
|
|
@ -103,3 +103,6 @@ bind-key W choose-window 'swap-window -t "%%"'
|
||||||
bind A command-prompt "rename-window \"%%\""
|
bind A command-prompt "rename-window \"%%\""
|
||||||
|
|
||||||
bind C customize-mode
|
bind C customize-mode
|
||||||
|
|
||||||
|
bind-key -T copy-mode-vi n send-keys -X next-prompt
|
||||||
|
bind-key -T copy-mode-vi p send-keys -X previous-prompt
|
||||||
|
|
Loading…
Reference in New Issue
Block a user