1 2setopt autocd nomatch notify interactive_comments inc_append_history 3unsetopt beep extendedglob share_history 4 5# https://superuser.com/questions/476532/how-can-i-make-zshs-vi-mode-behave-more-like-bashs-vi-mode 6vi-search-fix() { 7 zle vi-cmd-mode 8 zle .vi-history-search-backward 9} 10autoload vi-search-fix 11zle -N vi-search-fix 12bindkey -M viins '\e/' vi-search-fix 13 14bindkey -v 15autoload -Uz edit-command-line 16zle -N edit-command-line 17bindkey -M vicmd V edit-command-line 18 19autoload zmv 20 21# set window title 22# https://wiki.archlinux.org/title/zsh#xterm_title 23autoload -Uz add-zsh-hook 24 25function xterm_title_precmd () { 26 print -Pn -- '\e]2;%n@%m:%~\a' 27} 28 29function xterm_title_preexec () { 30 print -Pn -- '\e]2;%n@%m:%~ %# ' && print -n -- "${(q)1}\a" 31} 32 33if [[ "$TERM" != "linux" ]]; then 34 add-zsh-hook -Uz precmd xterm_title_precmd 35 add-zsh-hook -Uz preexec xterm_title_preexec 36fi 37 38 39autoload -Uz up-line-or-beginning-search down-line-or-beginning-search 40zle -N up-line-or-beginning-search 41zle -N down-line-or-beginning-search 42 43typeset -g -A key 44 45# ANSI escape codes 46 47key[Up]="^[[A" 48key[Down]="^[[B" 49key[Shift-Tab]="^[[Z" 50key[Control-Left]="^[[1;5D" 51key[Control-Right]="^[[1;5C" 52key[Control-Backspace]="^H" 53key[Control-Delete]="^[[3;5~" 54key[Control-R]="^R" 55key[Alt-Left]="^[[1;3D" 56key[Alt-Right]="^[[1;3C" 57key[Alt-Backspace]="^[^?" 58key[Alt-Delete]="^[[3;3~" 59key[Shift-Left]="^[[1;2D" 60key[Shift-Right]="^[[1;2C" 61key[Shift-Delete]="^[[3;2~" 62key[Delete]="^[[3~" 63 64# see zshzle 65 66bindkey "${key[Up]}" up-line-or-beginning-search 67bindkey "${key[Down]}" down-line-or-beginning-search 68bindkey "${key[Shift-Tab]}" reverse-menu-complete 69# uses WORDCHARS 70bindkey "${key[Control-Left]}" backward-word 71bindkey "${key[Control-Right]}" forward-word 72bindkey "${key[Control-Backspace]}" backward-kill-word 73bindkey "${key[Control-Delete]}" kill-word 74 75bindkey "${key[Alt-Left]}" vi-backward-word 76bindkey "${key[Alt-Right]}" vi-forward-word 77bindkey "${key[Alt-Backspace]}" vi-backward-kill-word 78bindkey "${key[Alt-Delete]}" kill-word 79 80bindkey "${key[Shift-Left]}" emacs-backward-word 81bindkey "${key[Shift-Right]}" emacs-forward-word 82bindkey "${key[Shift-Delete]}" kill-word 83 84bindkey "${key[Delete]}" delete-char 85 86# https://github.com/spaceship-prompt/spaceship-prompt/issues/91#issuecomment-327996599 87bindkey "^?" backward-delete-char 88 89# https://unix.stackexchange.com/a/298844 90b() ( yad --info --text "$(date '+%Y-%m-%d %H.%M.%S')\n$(pwd)" --width=150 & while true; do spd-say -t female1 -w "beep beep beep"; sleep 1; done; ) 91 92export FZF_TMUX=1 93export FZF_TMUX_OPTS='-d50%' # fzf-tmux --help 94export FZF_DEFAULT_COMMAND="find . -maxdepth 5 \( -path '*/.*' -prune \) -o -print" 95export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" 96export FZF_ALT_C_COMMAND="find . -maxdepth 5 \( -path '*/.*' -prune \) -o -type d -print" 97 98if [ -n "${commands[fzf-share]}" ]; then 99 source "$(fzf-share)/key-bindings.zsh" 100 source "$(fzf-share)/completion.zsh" 101fi 102 103wait-ssh() { 104 while ! timeout 1 ping $1 -c 1; do sleep 1; done; ssh $1 105} 106 107# use ledger bash completions 108autoload bashcompinit 109bashcompinit 110if [ -f /run/current-system/sw/share/bash-completion/completions/ledger.bash ]; then 111 source /run/current-system/sw/share/bash-completion/completions/ledger.bash 112fi 113