Created
February 20, 2017 17:49
-
-
Save cdornsife/096141d3d89d4b8fe10650a2966af951 to your computer and use it in GitHub Desktop.
Zsh forever history
This file contains hidden or 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
| #set history size | |
| export HISTSIZE=5000 | |
| #save history after logout | |
| export SAVEHIST=5000 | |
| #history file | |
| export HISTFILE=~/.zhistory | |
| #append into history file | |
| setopt INC_APPEND_HISTORY | |
| #save only one command if 2 common are same and consistent | |
| setopt HIST_IGNORE_DUPS | |
| #add timestamp for each entry | |
| setopt EXTENDED_HISTORY | |
| # Store the last command in a dated history file | |
| precmd(){ | |
| if [ "$(id -u)" -ne 0 ]; | |
| then | |
| echo "$(date "+%Y-%m-%d.%H:%M:%S") $(pwd) $(history | awk 'END{$1=""; print $0}')" >> ~/.logs/bash-history-$(date "+%Y-%m-%d").log; | |
| fi | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment