Last active
July 3, 2019 11:52
-
-
Save cfstras/8824f4337c6f7d79dbb3fa3708645b0d to your computer and use it in GitHub Desktop.
Bash configuration for better history archive
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
# first, install fzf | |
# https://github.com/junegunn/fzf | |
# Windows: | |
# choco install fzf | |
# Arch: | |
# sudo pacman -S fzf | |
# Mac: | |
# brew install fzf | |
# $(brew --prefix)/opt/fzf/install | |
# use this block with fzf | |
HISTCONTROL="ignoredups" | |
unset HISTFILESIZE | |
PROMPT_COMMAND='history -a' | |
##################### | |
# use this block to create one history file per shell (harder to search, but better archival) -- doesn't work with fzf | |
HOSTNAME="$(hostname)" | |
HOSTNAME_SHORT="${HOSTNAME%%.*}" | |
HISTCONTROL="ignoredups" | |
unset HISTFILESIZE | |
HISTFILE="${HOME}/.history/$(date -u +%Y/%m/%d.%H.%M.%S)_${HOSTNAME_SHORT}_$$" | |
PROMPT_COMMAND='mkdir -p $(dirname "${HISTFILE}")&&history -a' | |
#FZF_CTRL_R_OPTS= | |
hag () | |
{ | |
find ~/.history/ -type f | sort | xargs -d "\n" ag "$@" | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment