zshrc update

This commit is contained in:
Luke Smith 2020-04-08 11:34:45 -04:00
parent 38497bc704
commit f68f3119c1
No known key found for this signature in database
GPG key ID: 4C50B54A911F6252

View file

@ -1,19 +1,30 @@
# Luke's config for the Zoomer Shell # Luke's config for the Zoomer Shell
autoload -U colors && colors # Enable colors and change prompt:
autoload -U colors && colors # Load colors
PS1="%B%{$fg[red]%}[%{$fg[yellow]%}%n%{$fg[green]%}@%{$fg[blue]%}%M %{$fg[magenta]%}%~%{$fg[red]%}]%{$reset_color%}$%b " PS1="%B%{$fg[red]%}[%{$fg[yellow]%}%n%{$fg[green]%}@%{$fg[blue]%}%M %{$fg[magenta]%}%~%{$fg[red]%}]%{$reset_color%}$%b "
setopt autocd # Automatically cd into typed directory.
stty stop undef # Disable ctrl-s to freeze terminal.
# History in cache directory:
HISTSIZE=10000
SAVEHIST=10000
HISTFILE=~/.cache/zsh/history
# Load aliases and shortcuts if existent. # Load aliases and shortcuts if existent.
[ -f "$HOME/.config/shortcutrc" ] && source "$HOME/.config/shortcutrc" [ -f "$HOME/.config/shortcutrc" ] && source "$HOME/.config/shortcutrc"
[ -f "$HOME/.config/aliasrc" ] && source "$HOME/.config/aliasrc" [ -f "$HOME/.config/aliasrc" ] && source "$HOME/.config/aliasrc"
# Basic auto/tab complete:
autoload -U compinit autoload -U compinit
zstyle ':completion:*' menu select zstyle ':completion:*' menu select
zmodload zsh/complist zmodload zsh/complist
compinit compinit
_comp_options+=(globdots) # Include hidden files.
# Include hidden files in autocomplete: # vi mode
_comp_options+=(globdots) bindkey -v
export KEYTIMEOUT=1
# Use vim keys in tab complete menu: # Use vim keys in tab complete menu:
bindkey -M menuselect 'h' vi-backward-char bindkey -M menuselect 'h' vi-backward-char
@ -22,14 +33,11 @@ bindkey -M menuselect 'l' vi-forward-char
bindkey -M menuselect 'j' vi-down-line-or-history bindkey -M menuselect 'j' vi-down-line-or-history
bindkey -v '^?' backward-delete-char bindkey -v '^?' backward-delete-char
export KEYTIMEOUT=1
# Change cursor shape for different vi modes. # Change cursor shape for different vi modes.
function zle-keymap-select { function zle-keymap-select {
if [[ ${KEYMAP} == vicmd ]] || if [[ ${KEYMAP} == vicmd ]] ||
[[ $1 = 'block' ]]; then [[ $1 = 'block' ]]; then
echo -ne '\e[1 q' echo -ne '\e[1 q'
elif [[ ${KEYMAP} == main ]] || elif [[ ${KEYMAP} == main ]] ||
[[ ${KEYMAP} == viins ]] || [[ ${KEYMAP} == viins ]] ||
[[ ${KEYMAP} = '' ]] || [[ ${KEYMAP} = '' ]] ||
@ -38,17 +46,13 @@ function zle-keymap-select {
fi fi
} }
zle -N zle-keymap-select zle -N zle-keymap-select
zle-line-init() { zle-line-init() {
zle -K viins # initiate `vi insert` as keymap (can be removed if `bindkey -V` has been set elsewhere) zle -K viins # initiate `vi insert` as keymap (can be removed if `bindkey -V` has been set elsewhere)
echo -ne "\e[5 q" echo -ne "\e[5 q"
} }
zle -N zle-line-init zle -N zle-line-init
echo -ne '\e[5 q' # Use beam shape cursor on startup.
# Use beam shape cursor on startup. preexec() { echo -ne '\e[5 q' ;} # Use beam shape cursor for each new prompt.
echo -ne '\e[5 q'
# Use beam shape cursor for each new prompt.
preexec() { echo -ne '\e[5 q' ;}
# Use lf to switch directories and bind it to ctrl-o # Use lf to switch directories and bind it to ctrl-o
lfcd () { lfcd () {
@ -57,15 +61,20 @@ lfcd () {
if [ -f "$tmp" ]; then if [ -f "$tmp" ]; then
dir="$(cat "$tmp")" dir="$(cat "$tmp")"
rm -f "$tmp" rm -f "$tmp"
if [ -d "$dir" ]; then [ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir"
if [ "$dir" != "$(pwd)" ]; then
cd "$dir"
fi
fi
fi fi
} }
bindkey -s '^o' 'lfcd\n'
bindkey -s '^o' 'lfcd\n' # zsh bindkey -s '^a' 'bc -l\n'
bindkey -s '^f' 'cd "$(dirname "$(fzf)")"\n'
bindkey '^[[P' delete-char
# Edit line in vim with ctrl-e:
autoload edit-command-line; zle -N edit-command-line
bindkey '^e' edit-command-line
# Load zsh-syntax-highlighting; should be last. # Load zsh-syntax-highlighting; should be last.
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh 2>/dev/null source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh 2>/dev/null