| 1 | autoload -U colors && colors # Load colors |
| 2 | PS1="%B%{$fg[red]%}[%{$fg[yellow]%}%n%{$fg[green]%}@%{$fg[blue]%}%M %{$fg[magenta]%}%~%{$fg[red]%}]%{$reset_color%}$%b " |
| 3 | setopt autocd # Automatically cd into typed directory. |
| 4 | stty stop undef # Disable ctrl-s to freeze terminal. |
| 5 | |
| 6 | # History in cache directory: |
| 7 | HISTSIZE=1000000 |
| 8 | SAVEHIST=1000000 |
| 9 | HISTFILE=~/.cache/history |
| 10 | |
| 11 | # Load aliases if existent. |
| 12 | [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/aliasrc" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/aliasrc" |
| 13 | |
| 14 | # Basic auto/tab complete: |
| 15 | autoload -U compinit |
| 16 | zstyle ':completion:*' menu select |
| 17 | zmodload zsh/complist |
| 18 | compinit |
| 19 | _comp_options+=(globdots) # Include hidden files. |
| 20 | |
| 21 | # vi mode |
| 22 | bindkey -v |
| 23 | export KEYTIMEOUT=1 |
| 24 | |
| 25 | # Use vim keys in tab complete menu: |
| 26 | bindkey -M menuselect 'h' vi-backward-char |
| 27 | bindkey -M menuselect 'k' vi-up-line-or-history |
| 28 | bindkey -M menuselect 'l' vi-forward-char |
| 29 | bindkey -M menuselect 'j' vi-down-line-or-history |
| 30 | bindkey -v '^?' backward-delete-char |
| 31 | |
| 32 | # Change cursor shape for different vi modes. |
| 33 | function zle-keymap-select () { |
| 34 | case $KEYMAP in |
| 35 | vicmd) echo -ne '\e[1 q';; # block |
| 36 | viins|main) echo -ne '\e[5 q';; # beam |
| 37 | esac |
| 38 | } |
| 39 | |
| 40 | zle -N zle-keymap-select |
| 41 | zle-line-init() { |
| 42 | zle -K viins # initiate `vi insert` as keymap (can be removed if `bindkey -V` has been set elsewhere) |
| 43 | echo -ne "\e[5 q" |
| 44 | } |
| 45 | zle -N zle-line-init |
| 46 | echo -ne '\e[5 q' # Use beam shape cursor on startup. |
| 47 | preexec() { echo -ne '\e[5 q' ;} # Use beam shape cursor for each new prompt. |
| 48 | |
| 49 | # |
| 50 | # Use lf to switch directories and bind it to ctrl-o |
| 51 | lfcd () { |
| 52 | tmp="$(mktemp -uq)" |
| 53 | trap 'rm -f $tmp >/dev/null 2>&1' HUP INT QUIT TERM PWR EXIT |
| 54 | lf -last-dir-path="$tmp" "$@" |
| 55 | if [ -f "$tmp" ]; then |
| 56 | dir="$(cat "$tmp")" |
| 57 | [ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir" |
| 58 | fi |
| 59 | } |
| 60 | bindkey -s '^o' '^ulfcd\n' |
| 61 | |
| 62 | # Edit line in vim with ctrl-e: |
| 63 | autoload edit-command-line; zle -N edit-command-line |
| 64 | bindkey '^e' edit-command-line |
| 65 | |
| 66 | # Enable searching through history |
| 67 | bindkey '^R' history-incremental-pattern-search-backward |
| 68 | |
| 69 | #loeading syntax highlighter and autosgguestions plugin. should be last. |
| 70 | source /usr/share/zsh/plugins/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh 2>/dev/null |
| 71 | source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh |
| 72 | |
| 73 | # Load pywal colors |
| 74 | # (cat ~/.cache/wal/sequences &) |