.zshrc (2925B)
1 # Enable colors and change prompt: 2 autoload -U colors && colors # Load colors 3 PS1='%{$fg[white]%}%n%{$fg[white]%}@%{$fg[white]%}%M %{$fg[yellow]%}%~%{$reset_color%}%b${vcs_info_msg_0_} $ ' 4 setopt autocd # Automatically cd into typed directory. 5 stty stop undef # Disable ctrl-s to freeze terminal. 6 setopt interactive_comments 7 setopt prompt_subst 8 # History in cache directory: 9 HISTSIZE=10000000 10 SAVEHIST=10000000 11 HISTFILE="${XDG_CACHE_HOME:-$HOME/.cache}/zsh/history" 12 setopt inc_append_history 13 14 autoload -Uz vcs_info # enable vcs_info 15 precmd () { vcs_info } 16 zstyle ':vcs_info:*' formats ' %s(%F{blue}%b%f)' # git(main) 17 18 # Load aliases and shortcuts if existent. 19 [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutrc" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutrc" 20 [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutenvrc" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutenvrc" 21 [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/aliasrc" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/aliasrc" 22 [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshnameddirrc" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshnameddirrc" 23 24 # Basic auto/tab complete: 25 autoload -U compinit 26 zstyle ':completion:*' menu select 27 zmodload zsh/complist 28 compinit 29 _comp_options+=(globdots) # Include hidden files. 30 31 # vi mode 32 bindkey -v 33 export KEYTIMEOUT=1 34 35 # Use vim keys in tab complete menu: 36 bindkey -M menuselect 'h' vi-backward-char 37 bindkey -M menuselect 'k' vi-up-line-or-history 38 bindkey -M menuselect 'l' vi-forward-char 39 bindkey -M menuselect 'j' vi-down-line-or-history 40 bindkey -v '^?' backward-delete-char 41 42 # Change cursor shape for different vi modes. 43 function zle-keymap-select () { 44 case $KEYMAP in 45 vicmd) echo -ne '\e[6 q';; 46 viins|main) echo -ne '\033[0 q';; 47 esac 48 } 49 zle -N zle-keymap-select 50 zle-line-init() { 51 zle -K viins # initiate `vi insert` as keymap (can be removed if `bindkey -V` has been set elsewhere) 52 echo -ne '\033[0 q' 53 } 54 zle -N zle-line-init 55 56 function preexec { 57 print -Pn "\e]0;${(q)1}\e\\" 58 } 59 60 # Use yazi to switch directories and bind it to ctrl-o 61 function y() { 62 local tmp="$(mktemp -t "yazi-cwd.XXXXXX")" cwd 63 yazi "$@" --cwd-file="$tmp" 64 if cwd="$(command cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then 65 builtin cd -- "$cwd" 66 fi 67 rm -f -- "$tmp" > /dev/null 68 } 69 70 bindkey -s '^o' '^uy\n' 71 72 bindkey -s '^a' '^ubc -lq\n' 73 74 bindkey -s '^f' '^ucd "$(dirname "$(fzf)")"\n' 75 76 bindkey '^[[P' delete-char 77 78 # Edit line in vim with ctrl-e: 79 autoload edit-command-line; zle -N edit-command-line 80 bindkey '^e' edit-command-line 81 bindkey -M vicmd '^[[P' vi-delete-char 82 bindkey -M vicmd '^e' edit-command-line 83 bindkey -M visual '^[[P' vi-delete 84 85 source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh 86 # Load syntax highlighting; should be last. 87 source /usr/share/zsh/plugins/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh 2>/dev/null