commit eed12592960d7824621c045ca1e2a71f00903b0f
parent 36afebd9778a8048ac5212d52c797b50b1615cbd
Author: Alex Balgavy <alexander.balgavy@spaceapplications.com>
Date: Fri, 24 Oct 2025 21:23:58 +0200
zshrc: more shell config improvements
Diffstat:
2 files changed, 8 insertions(+), 42 deletions(-)
diff --git a/shell/oh-my-zsh-defaults/history.zsh b/shell/oh-my-zsh-defaults/history.zsh
@@ -1,39 +0,0 @@
-## History wrapper
-function omz_history {
- local clear list
- zparseopts -E c=clear l=list
-
- if [[ -n "$clear" ]]; then
- # if -c provided, clobber the history file
- echo -n >| "$HISTFILE"
- echo >&2 History file deleted. Reload the session to see its effects.
- elif [[ -n "$list" ]]; then
- # if -l provided, run as if calling `fc' directly
- builtin fc "$@"
- else
- # unless a number is provided, show all history events (starting from 1)
- [[ ${@[-1]-} = *[0-9]* ]] && builtin fc -l "$@" || builtin fc -l "$@" 1
- fi
-}
-
-# Timestamp format
-case ${HIST_STAMPS-} in
- "mm/dd/yyyy") alias history='omz_history -f' ;;
- "dd.mm.yyyy") alias history='omz_history -E' ;;
- "yyyy-mm-dd") alias history='omz_history -i' ;;
- "") alias history='omz_history' ;;
- *) alias history="omz_history -t '$HIST_STAMPS'" ;;
-esac
-
-## History file configuration
-HISTSIZE=50000
-SAVEHIST=10000
-
-## History command configuration
-setopt extended_history # record timestamp of command in HISTFILE
-setopt hist_expire_dups_first # delete duplicates first when HISTFILE size exceeds HISTSIZE
-setopt hist_ignore_dups # ignore duplicated commands history list
-setopt hist_ignore_space # ignore commands that start with space
-setopt hist_verify # show command with history expansion to user before running it
-setopt inc_append_history # add commands to HISTFILE in order of execution
-setopt share_history # share command history data
diff --git a/shell/zshrc b/shell/zshrc
@@ -249,6 +249,7 @@ export RIPGREP_CONFIG_PATH="$XDG_CONFIG_HOME/ripgrep/config"
export ZDOTDIR=$HOME/.config/zsh
export HISTFILE=$ZDOTDIR/.zsh_history
export GEM_HOME=$XDG_DATA_HOME/.gems
+export CARGO_TARGET_DIR=$XDG_CACHE_HOME/cargo/target/
# }}}
# Paths {{{1
@@ -339,6 +340,7 @@ mkcd() { mkdir -p -- "$1" && cd -P -- "$1" || return; } # make d
procinfo() { pgrep -f "$1"; } # get info about a process (by name)
rmempty() { find "${1-.}" -type d -empty -depth -delete; } # remove empty directories
hr() { : $((i=0)); while [ $((i<$(tput cols))) -ne 0 ]; do printf "#"; _=$((i=i+1)); done; echo; } # insert a <hr> in the terminal
+history() { builtin fc $@ -l 1 -1; }
vimq() { vim -q <(eval "$(fc -nl -1 | sed 's/^rg\b/rgv/')"); } # load results of last command (often ag) in vim quickfix. eval necessary to handle escaped quotes.
nls() { printf $((`ls -l | wc -l | xargs echo` - 1)); } # Count the number of files in the directory
reload-completions() { rm $ZDOTDIR/.zcompdump && compinit; }
@@ -508,7 +510,6 @@ setopt alwaystoend # On completion, move cursor to end of word
setopt autocd # If I forget 'cd' before a path
setopt autopushd # Make cd push old directory onto stack
setopt completeinword # Completion from both ends of word
-setopt extendedhistory # Save timestamp and duration of commands in histfile
setopt interactivecomments # Allow comments
setopt monitor # Allow job control
setopt nocaseglob # Globs should be case insensitive
@@ -518,18 +519,23 @@ setopt pushdignoredups # Don't pushd duplicate directories
setopt pushdminus # Exchange meanings of + and - on directory stack
# History options
+## History file configuration
+HISTSIZE=100000
+SAVEHIST=100000
+setopt extendedhistory # Save timestamp and duration of commands in histfile
setopt sharehistory # Import commands from histfile and append typed to histfile
setopt appendhistory # Append to history
setopt incappendhistory # Append immediately, not at shell exit
-setopt histexpiredupsfirst # When trimming history, remove duplicates first
setopt histignoredups # Don't save command into history if duplicate of previous
setopt histignorespace # Don't save command into history if starts with space
setopt histfindnodups # Ignore duplicates when searching
setopt histreduceblanks # Remove blank lines from history
setopt histverify # Show expansion first before executing
+setopt histexpiredupsfirst # Expire duplicates first when trimming
# Enable extra completions
# fpath=($DOTFILES/shell/zsh-completions/src $DOTFILES/shell/osx-zsh-completions/ $DOTFILES/shell/zsh-completions-mine/ $fpath)
+# fpath=($DOTFILES/shell/zsh-completions-mine/ $fpath)
# Smarter completion initialization
autoload -Uz compinit
if [ "$(date +'%j')" != "$(stat -f '%Sm' -t '%j' $ZDOTDIR/.zcompdump 2>/dev/null)" ]; then
@@ -539,7 +545,6 @@ else
fi
. $DOTFILES/shell/oh-my-zsh-defaults/completion.zsh
. $DOTFILES/shell/oh-my-zsh-defaults/directories.zsh
-. $DOTFILES/shell/oh-my-zsh-defaults/history.zsh
. $DOTFILES/shell/oh-my-zsh-defaults/keys.zsh
# Allow pasting bare URLs