Compare commits

...

4 Commits

Author SHA1 Message Date
2c189c87e6 Support changing cursor shape in iTerm2 in tmux
Depends on setting the following in `.tmux.conf`:

    set -ga terminal-overrides '*:Ss=\E]1337;CursorShape=%p1%d\7'

This allows changing the iTerm2 cursor shape using the same escape
sequences as used for VTE compatible terminals.
2018-01-02 16:54:49 +00:00
a450b3cb45 Fix cursor shape change bug in tmux
Sending escape sequences directly from zsh and bypassing tmux results in
the wrong cursor shape when switching between panes which no longer
reflect the current zsh vi mode.

When using ZTE compatible terminals tmux supports tracking cursor shape
changes on a per pane basis using a suitable `terminal-override`, this
allows zsh and vim to behave as if they are not operating in tmux and
everything works as expected. However, so far I've not been able to
reproduce this behaviour in iTerm2.
2018-01-02 16:54:49 +00:00
2846e7d68e Enable reverse order completions 2018-01-02 16:54:49 +00:00
9da4d8ee71 Add autosuggestions plugin
Fish-like autosuggestions for zsh
2018-01-02 16:54:45 +00:00
2 changed files with 26 additions and 15 deletions

View File

@ -17,6 +17,7 @@
src: prompt_fresh_setup
dst: ~/.local/share/zsh/site-functions/prompt_fresh_setup
- repo:
- https://github.com/zsh-users/zsh-syntax-highlighting.git
- https://github.com/zsh-users/zsh-autosuggestions.git
- https://github.com/zsh-users/zsh-history-substring-search.git
- https://github.com/zsh-users/zsh-syntax-highlighting.git
- message: zsh will be the default prompt after next login

38
zshrc
View File

@ -3,8 +3,12 @@
# Load plugin scripts
plugin-load() { source ~/.config/zsh/$1/$1.plugin.zsh }
plugin-load zsh-syntax-highlighting
plugin-load zsh-autosuggestions
plugin-load zsh-history-substring-search
plugin-load zsh-syntax-highlighting
# Disable non end-of-line autosuggest accept widgets
ZSH_AUTOSUGGEST_ACCEPT_WIDGETS=(end-of-line vi-end-of-line)
# Remove duplicates from history
setopt hist_ignore_all_dups
@ -50,6 +54,10 @@ bindkey -M vicmd 'gcc' vi-pound-insert
# TODO: vi-pipe???
# Enable accepting autosuggestions
bindkey '^O' forward-word
bindkey '^P' autosuggest-accept
# Enable substring history search with 'j' and 'k'
bindkey -M vicmd 'k' history-substring-search-up
bindkey -M vicmd 'j' history-substring-search-down
@ -61,26 +69,28 @@ bindkey -M vicmd 'K' run-help
# Disable Ex mode with ':'
bindkey -rM vicmd ':'
# Enable '<Shirt><Tab>' reverse order completions
bindkey '^[[Z' reverse-menu-complete
# Use editor to edit command line with '<Ctrl>V'
autoload -U edit-command-line
zle -N edit-command-line
bindkey -M vicmd '^V' edit-command-line
# Get the shells parent process name.
ppid_name() { echo $(ps -p $(ps -p $(echo $$) -o ppid=) -o comm=) }
# Enable changing cursor shape based on vi mode
if [ "$TMUX" != "" ]; then
tmux_before="\EPtmux;\E"
tmux_after="\E\\"
if [ "$ITERM_PROFILE" != "" ] && [ "$TMUX" = "" ]; then
# iTerm2 cursor shape escape sequences outside tmux
cursor_block="\e]50;CursorShape=0\C-G"
cursor_line="\e]50;CursorShape=1\C-G"
elif [ "$(ppid_name)" != "python2" ]; then
# iTerm2 inside tmux or VTE compatible cursor shape escape sequences,
# exclude Guake even though it's VTE based it doesn't like these
cursor_block="\e[2 q"
cursor_line="\e[6 q"
fi
if [ "$ITERM_SESSION_ID" != "" ]; then
# iterm2 cursor shape escape sequences
cursor_block="$tmux_before\E]50;CursorShape=0\C-G$tmux_after"
cursor_line="$tmux_before\E]50;CursorShape=1\C-G$tmux_after"
else
# VTE compatible cursor shape escape sequences
cursor_block="$tmux_before\E[2 q$tmux_after"
cursor_line="$tmux_before\E[6 q$tmux_after"
fi
unset tmux_before tmux_after
if [[ ! -z "$cursor_block" && ! -z "$cursor_line" ]]; then
# Change cursor shape when vi mode changes