2023-01-03 07:57:46 +01:00
|
|
|
autoload -U colors && colors
|
|
|
|
autoload -U complist
|
|
|
|
|
|
|
|
# Set vim mode
|
|
|
|
set -o vi
|
|
|
|
# Allow editing of current line in $EDITOR using command mode V
|
|
|
|
autoload -U edit-command-line
|
|
|
|
zle -N edit-command-line
|
|
|
|
bindkey -M vicmd v edit-command-line
|
|
|
|
|
2023-01-03 07:57:57 +01:00
|
|
|
# Use vim keys within completion
|
|
|
|
zmodload zsh/complist
|
|
|
|
bindkey -M menuselect 'h' vi-backward-char
|
|
|
|
bindkey -M menuselect 'k' vi-up-line-or-history
|
|
|
|
bindkey -M menuselect 'l' vi-forward-char
|
|
|
|
bindkey -M menuselect 'j' vi-down-line-or-history
|
|
|
|
|
2023-01-03 08:06:26 +01:00
|
|
|
# Add vim like text objects
|
2023-01-03 07:59:00 +01:00
|
|
|
autoload -Uz select-bracketed select-quoted
|
|
|
|
zle -N select-quoted
|
|
|
|
zle -N select-bracketed
|
|
|
|
for km in viopp visual; do
|
|
|
|
bindkey -M $km -- '-' vi-up-line-or-history
|
|
|
|
for c in {a,i}${(s..)^:-\'\"\`\|,./:;=+@}; do
|
2023-01-03 08:06:26 +01:00
|
|
|
bindkey -M $km $c select-quoted
|
2023-01-03 07:59:00 +01:00
|
|
|
done
|
|
|
|
for c in {a,i}${(s..)^:-'()[]{}<>bB'}; do
|
2023-01-03 08:06:26 +01:00
|
|
|
bindkey -M $km $c select-bracketed
|
2023-01-03 07:59:00 +01:00
|
|
|
done
|
|
|
|
done
|
|
|
|
|
2023-01-03 08:06:26 +01:00
|
|
|
# Set options
|
|
|
|
|
2023-01-03 07:57:46 +01:00
|
|
|
# also complete defined alias
|
|
|
|
setopt completealiases
|
|
|
|
# Correct mistyped commands
|
|
|
|
setopt correctall
|
|
|
|
# Try to make the completion list smaller (occupying less lines) by printing the matches in columns with different widths.
|
|
|
|
setopt list_packed
|
|
|
|
# When listing files that are possible completions, show the type of each file with a trailing identifying mark.
|
|
|
|
setopt list_types
|
|
|
|
|
2023-01-03 08:06:26 +01:00
|
|
|
# Set Prompt
|
2023-02-18 11:19:29 +01:00
|
|
|
autoload -Uz add-zsh-hook
|
|
|
|
setopt promptsubst
|
|
|
|
|
|
|
|
nix_subshell () {
|
|
|
|
prompt_color="blue"
|
|
|
|
# check for IN_NIX_SHELL
|
|
|
|
if [[ "$IN_NIX_SHELL" ]]; then
|
|
|
|
prompt_color="yellow"
|
2024-02-20 08:09:35 +01:00
|
|
|
export SHELL=$(which zsh)
|
2023-02-18 11:19:29 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
add-zsh-hook precmd nix_subshell
|
|
|
|
|
2023-03-08 10:03:44 +01:00
|
|
|
PROMPT=$'\n%{$fg[${prompt_color}]%}%1~ > %{$reset_color%}'
|
2023-01-03 07:57:46 +01:00
|
|
|
|
2023-01-03 08:43:05 +01:00
|
|
|
zstyle ':completion:*:descriptions' format '%F{blue}-- %d --%f'
|
|
|
|
zstyle ':completion:*:messages' format ' %F{purple} -- %d --%f'
|
|
|
|
zstyle ':completion:*:warnings' format '%F{yellow} -- Sorry no matches -- %d%b%f'
|
|
|
|
zstyle ':completion:*:*:*:*:corrections' format '%F{yellow}!- %d (errors: %e) -!%f'
|
2023-01-03 07:57:46 +01:00
|
|
|
zstyle ':completion:*' menu select
|
|
|
|
zstyle ':completion:*' use-cache on
|
2023-01-03 08:43:05 +01:00
|
|
|
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
|
|
|
|
|
2023-01-04 15:45:52 +01:00
|
|
|
zstyle ':completion:*' completer _extensions _complete
|
2023-01-03 07:57:46 +01:00
|
|
|
|
2023-01-03 08:06:26 +01:00
|
|
|
zstyle ':completion:*' group-name ''
|
2023-01-03 07:57:46 +01:00
|
|
|
zstyle ':completion::complete:git-checkout:argument-rest:' group-order heads-local heads-remote commit-tags
|
|
|
|
zstyle ':completion::complete:git-checkout:argument-rest:commits' command 'echo'
|
|
|
|
zstyle ':completion::complete:git-checkout:argument-rest:valid-ref-names' command 'echo'
|
|
|
|
zstyle ':completion::complete:git-checkout:argument-rest:remote-branch-refs-noprefix' command 'echo'
|
2023-03-02 12:18:46 +01:00
|
|
|
|
|
|
|
|
|
|
|
# Configuration for fzf-tab, see: https://github.com/Aloxaf/fzf-tab#configure
|
|
|
|
# disable sort when completing `git checkout`
|
|
|
|
zstyle ':completion:*:git-checkout:*' sort false
|
|
|
|
# set descriptions format to enable group support
|
|
|
|
zstyle ':completion:*:descriptions' format '[%d]'
|
|
|
|
# set list-colors to enable filename colorizing
|
|
|
|
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
|
|
|
|
# switch group using `,` and `.`
|
|
|
|
zstyle ':fzf-tab:*' switch-group ',' '.'
|