dotfiles-x1163c5d80
.zshrc lukesmith stuff copied :)
+50 −6
1 file changed
- M .config/zsh/.zshrc +50 −6
| @@ -4,11 +4,12 @@ setopt autocd # Automatically cd into typed directory. | |||
| 4 | 4 | stty stop undef # Disable ctrl-s to freeze terminal. | |
| 5 | 5 | ||
| 6 | 6 | # History in cache directory: | |
| 7 | − | HISTSIZE=1000 | |
| 8 | − | SAVEHIST=1000 | |
| 7 | + | HISTSIZE=10000 | |
| 8 | + | SAVEHIST=10000 | |
| 9 | 9 | HISTFILE=~/.cache/history | |
| 10 | 10 | ||
| 11 | − | source "$XDG_CONFIG_HOME/shell/aliasrc" | |
| 11 | + | # Load aliases if existent. | |
| 12 | + | [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/aliasrc" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/aliasrc" | |
| 12 | 13 | ||
| 13 | 14 | # Basic auto/tab complete: | |
| 14 | 15 | autoload -U compinit | |
| @@ -17,11 +18,54 @@ zmodload zsh/complist | |||
| 17 | 18 | compinit | |
| 18 | 19 | _comp_options+=(globdots) # Include hidden files. | |
| 19 | 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 | + | zle -N zle-keymap-select | |
| 40 | + | zle-line-init() { | |
| 41 | + | zle -K viins # initiate `vi insert` as keymap (can be removed if `bindkey -V` has been set elsewhere) | |
| 42 | + | echo -ne "\e[5 q" | |
| 43 | + | } | |
| 44 | + | zle -N zle-line-init | |
| 45 | + | echo -ne '\e[5 q' # Use beam shape cursor on startup. | |
| 46 | + | preexec() { echo -ne '\e[5 q' ;} # Use beam shape cursor for each new prompt. | |
| 47 | + | ||
| 48 | + | # Use lf to switch directories and bind it to ctrl-o | |
| 49 | + | lfcd () { | |
| 50 | + | tmp="$(mktemp -uq)" | |
| 51 | + | trap 'rm -f $tmp >/dev/null 2>&1' HUP INT QUIT TERM PWR EXIT | |
| 52 | + | lf -last-dir-path="$tmp" "$@" | |
| 53 | + | if [ -f "$tmp" ]; then | |
| 54 | + | dir="$(cat "$tmp")" | |
| 55 | + | [ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir" | |
| 56 | + | fi | |
| 57 | + | } | |
| 58 | + | bindkey -s '^o' '^ulfcd\n' | |
| 59 | + | ||
| 60 | + | # Edit line in vim with ctrl-e: | |
| 61 | + | autoload edit-command-line; zle -N edit-command-line | |
| 62 | + | bindkey '^e' edit-command-line | |
| 63 | + | ||
| 20 | 64 | # Enable searching through history | |
| 21 | 65 | bindkey '^R' history-incremental-pattern-search-backward | |
| 22 | 66 | ||
| 23 | − | cowsay "$(shuf -n 1 ~/.local/share/vocab/words.txt)" | |
| 24 | − | ||
| 25 | − | #should be last. | |
| 67 | + | #loeading syntax highlighter and autosgguestions plugin. should be last. | |
| 26 | 68 | source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh | |
| 27 | 69 | source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh | |
| 70 | + | ||
| 71 | + | cowsay "$(shuf -n 1 ~/.local/share/vocab/words.txt)" | |