From b5c39614c924942275f1cc6c9ea320875a8d9323 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Mon, 6 Nov 2023 23:12:47 +0100 Subject: [PATCH] nix: Added remaining of zshrc Basically added the whole file with little edits... sad :( --- config/nix/hm/common.nix | 5 +++ config/nix/hm/zshrc.sh | 70 +++++++++++++++++++++++++++++++++ config/shell/zshrc | 84 ---------------------------------------- 3 files changed, 75 insertions(+), 84 deletions(-) delete mode 100644 config/shell/zshrc diff --git a/config/nix/hm/common.nix b/config/nix/hm/common.nix index 3dacf87..b800181 100644 --- a/config/nix/hm/common.nix +++ b/config/nix/hm/common.nix @@ -13,6 +13,11 @@ historySubstringSearch.enable = true; initExtra = builtins.readFile ./zshrc.sh; defaultKeymap = "viins"; + history = { + size = 100000; + save = 100000; + expireDuplicatesFirst = true; + }; }; powerline-go = { enable = true; diff --git a/config/nix/hm/zshrc.sh b/config/nix/hm/zshrc.sh index 0e5bda3..5130f51 100644 --- a/config/nix/hm/zshrc.sh +++ b/config/nix/hm/zshrc.sh @@ -1,3 +1,10 @@ +# +# ZSH aliases and customizations +# Am not sure what everything does in there... +# + +# TODO Learn `setopt extendedglob` + # powerline-go duration support zmodload zsh/datetime function preexec() { @@ -40,3 +47,66 @@ bindkey -M vicmd v edit-command-line # bindkey -M vicmd 'k' history-substring-search-up # bindkey -M vicmd 'j' history-substring-search-down +# Autocompletion +autoload -Uz promptinit +promptinit + +# Color common prefix +zstyle -e ':completion:*:default' list-colors 'reply=("${PREFIX:+=(#bi)($PREFIX:t)(?)*==35=00}:${(s.:.)LS_COLORS}")' + + +setopt GLOBDOTS # Complete hidden files + +setopt NO_BEEP # that annoying beep goes away +# setopt NO_LIST_BEEP # beeping is only turned off for ambiguous completions +# +setopt AUTO_LIST # when the completion is ambiguous you get a list without having to type ^D +# setopt BASH_AUTO_LIST # the list only happens the second time you hit tab on an ambiguous completion +# setopt LIST_AMBIGUOUS # this is modified so that nothing is listed if there is an unambiguous prefix or suffix to be inserted --- this can be combined with BASH_AUTO_LIST, so that where both are applicable you need to hit tab three times for a listing +unsetopt REC_EXACT # if the string on the command line exactly matches one of the possible completions, it is accepted, even if there is another completion (i.e. that string with something else added) that also matches +unsetopt MENU_COMPLETE # one completion is always inserted completely, then when you hit TAB it changes to the next, and so on until you get back to where you started +unsetopt AUTO_MENU # you only get the menu behaviour when you hit TAB again on the ambiguous completion. +unsetopt AUTO_REMOVE_SLASH + +# Help +# TODO ~~Doesn't work (how ironic)~~ Works but it's just man? +autoload -Uz run-help +unalias run-help +alias help=run-help +autoload -Uz run-help-git +autoload -Uz run-help-ip +autoload -Uz run-help-openssl +autoload -Uz run-help-p4 +autoload -Uz run-help-sudo +autoload -Uz run-help-svk +autoload -Uz run-help-svn + +# Dir stack +DIRSTACKFILE="$HOME/.cache/zsh_dirstack" +if [[ -f $DIRSTACKFILE ]] && [[ $#dirstack -eq 0 ]]; then + dirstack=( ${(f)"$(< $DIRSTACKFILE)"} ) + # [[ -d $dirstack[1] ]] && cd $dirstack[1] +fi +chpwd() { + print -l $PWD ${(u)dirstack} >$DIRSTACKFILE +} + +DIRSTACKSIZE=20 + +setopt AUTO_PUSHD PUSHD_SILENT PUSHD_TO_HOME +setopt PUSHD_IGNORE_DUPS # Remove duplicate entries +setopt PUSHD_MINUS # This reverts the +/- operators. + + +# History + +# From https://unix.stackexchange.com/a/273863 +setopt BANG_HIST # Treat the '!' character specially during expansion. +setopt INC_APPEND_HISTORY # Write to the history file immediately, not when the shell exits. +setopt HIST_IGNORE_ALL_DUPS # Delete old recorded entry if new entry is a duplicate. +setopt HIST_FIND_NO_DUPS # Do not display a line previously found. +setopt HIST_SAVE_NO_DUPS # Don't write duplicate entries in the history file. +setopt HIST_REDUCE_BLANKS # Remove superfluous blanks before recording entry. +unsetopt HIST_VERIFY # Don't execute immediately upon history expansion. +unsetopt HIST_BEEP # Beep when accessing nonexistent history. + diff --git a/config/shell/zshrc b/config/shell/zshrc deleted file mode 100644 index faf0f50..0000000 --- a/config/shell/zshrc +++ /dev/null @@ -1,84 +0,0 @@ -#!/usr/bin/env zsh - -# -# ZSH aliases and customizations -# - -# TODO Learn `setopt extendedglob` - - -# Autocompletion -autoload -Uz promptinit -promptinit - -# Color common prefix -zstyle -e ':completion:*:default' list-colors 'reply=("${PREFIX:+=(#bi)($PREFIX:t)(?)*==35=00}:${(s.:.)LS_COLORS}")' - -setopt GLOBDOTS # Complete hidden files - -setopt NO_BEEP # that annoying beep goes away -# setopt NO_LIST_BEEP # beeping is only turned off for ambiguous completions -setopt AUTO_LIST # when the completion is ambiguous you get a list without having to type ^D -# setopt BASH_AUTO_LIST # the list only happens the second time you hit tab on an ambiguous completion -# setopt LIST_AMBIGUOUS # this is modified so that nothing is listed if there is an unambiguous prefix or suffix to be inserted --- this can be combined with BASH_AUTO_LIST, so that where both are applicable you need to hit tab three times for a listing -unsetopt REC_EXACT # if the string on the command line exactly matches one of the possible completions, it is accepted, even if there is another completion (i.e. that string with something else added) that also matches -unsetopt MENU_COMPLETE # one completion is always inserted completely, then when you hit TAB it changes to the next, and so on until you get back to where you started -unsetopt AUTO_MENU # you only get the menu behaviour when you hit TAB again on the ambiguous completion. -unsetopt AUTO_REMOVE_SLASH - -# Fuzzy matching all the way -# trysource /usr/share/fzf/completion.zsh -trysource /usr/share/fzf/key-bindings.zsh - -# Help -# TODO Doesn't work (how ironic) -autoload -Uz run-help -unalias run-help -alias help=run-help -autoload -Uz run-help-git -autoload -Uz run-help-ip -autoload -Uz run-help-openssl -autoload -Uz run-help-p4 -autoload -Uz run-help-sudo -autoload -Uz run-help-svk -autoload -Uz run-help-svn - -# Dir stack -DIRSTACKFILE="$HOME/.cache/zsh/dirs" -if [[ -f $DIRSTACKFILE ]] && [[ $#dirstack -eq 0 ]]; then - dirstack=( ${(f)"$(< $DIRSTACKFILE)"} ) - # [[ -d $dirstack[1] ]] && cd $dirstack[1] -fi -chpwd() { - print -l $PWD ${(u)dirstack} >$DIRSTACKFILE -} - -DIRSTACKSIZE=20 - -setopt AUTO_PUSHD PUSHD_SILENT PUSHD_TO_HOME -setopt PUSHD_IGNORE_DUPS # Remove duplicate entries -setopt PUSHD_MINUS # This reverts the +/- operators. - - -# Command not found -# (since we have syntax highlighting we are not forced to wait to see that we typed crap) -trysource /usr/share/doc/pkgfile/command-not-found.zsh - -# History - -# From https://unix.stackexchange.com/a/273863 -SAVEHIST=$HISTSIZE -setopt BANG_HIST # Treat the '!' character specially during expansion. -unsetopt EXTENDED_HISTORY # Write the history file in the ":start:elapsed;command" format. -setopt INC_APPEND_HISTORY # Write to the history file immediately, not when the shell exits. -setopt SHARE_HISTORY # Share history between all sessions. -setopt HIST_EXPIRE_DUPS_FIRST # Expire duplicate entries first when trimming history. -setopt HIST_IGNORE_DUPS # Don't record an entry that was just recorded again. -setopt HIST_IGNORE_ALL_DUPS # Delete old recorded entry if new entry is a duplicate. -setopt HIST_FIND_NO_DUPS # Do not display a line previously found. -setopt HIST_IGNORE_SPACE # Don't record an entry starting with a space. -setopt HIST_SAVE_NO_DUPS # Don't write duplicate entries in the history file. -setopt HIST_REDUCE_BLANKS # Remove superfluous blanks before recording entry. -unsetopt HIST_VERIFY # Don't execute immediately upon history expansion. -unsetopt HIST_BEEP # Beep when accessing nonexistent history. -