-
-
Save MartinHeinz/d233819a1041eae1700fa28ac8937229 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export ZSH="$HOME/.oh-my-zsh" | |
ZSH_THEME="ys" | |
HISTFILE="$HOME/.zsh_history" | |
HISTSIZE=10000000 | |
SAVEHIST=10000000 | |
HISTORY_IGNORE="(ls|cd|pwd|exit|cd)*" | |
HIST_STAMPS="yyyy-mm-dd" | |
bindkey "^E" history-incremental-search-backward | |
setopt 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_IGNORE_DUPS # Do not record an event that was just recorded again. | |
setopt HIST_IGNORE_ALL_DUPS # Delete an old recorded event if a new event is a duplicate. | |
setopt HIST_IGNORE_SPACE # Do not record an event starting with a space. | |
setopt HIST_SAVE_NO_DUPS # Do not write a duplicate event to the history file. | |
setopt HIST_VERIFY # Do not execute immediately upon history expansion. | |
setopt APPEND_HISTORY # append to history file (Default) | |
setopt HIST_NO_STORE # Don't store history commands | |
setopt HIST_REDUCE_BLANKS # Remove superfluous blanks from each command line being added to the history list. | |
plugins=(git fzf) | |
source $ZSH/oh-my-zsh.sh | |
export FZF_DEFAULT_COMMAND='ag --hidden -g ""' | |
source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh |
Just noticed there are two cd
commands in HISTORY_IGNORE="(ls|cd|pwd|exit|cd)*"
Nonetheless, I kindly suggest testing to ensure that syntax is working as expected. I thought the syntax needed to be something like:
HISTORY_IGNORE=('ls' 'ls *' 'cd' 'cd *' 'pwd' 'exit')
Thanks a lot for the article!
In case anyone runs into the same issue, I had to install fzf in order to have the ZSH fzf (just fzf
for me, instead of git fzf
) plugin work. Otherwise, I was prompted to specify FZF's installation dir.
Cheers
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great article! 👍 https://martinheinz.dev/blog/110
Some notes you may consider including in the blog post:
INC_APPEND_HISTORY
is not needed whenSHARE_HISTORY
is set since sharing history requires writing to the history file immediatelyTypically you would only enable one of:
HIST_IGNORE_DUPS
/HIST_SAVE_NO_DUPS
/HIST_IGNORE_ALL_DUPS
since their behaviors are unique:HIST_IGNORE_DUPS
only ignores consecutive duplicates, so if you enterls
, thencd
, thenls
again, the secondls
will be saved because it is not consecutiveHIST_SAVE_NO_DUPS
prevents a command from being saved if it is a duplicate of any existing entry in the history, but it doesn't remove earlier instances of a command when a new one is enteredHIST_IGNORE_ALL_DUPS
ensures that only the most recent instance of any command is preserved by removing earlier duplicates from the history whenever a command is re-enteredHIST_NO_STORE
is just another name forHIST_IGNORE_SPACE
so only one needs to be set (I preferHIST_IGNORE_SPACE
since it explicitly mentions the space which helps to remember what this option does)