4 ms·
It's a very custom solution. For Bash, in ~/.bashrc: export PROMPT_COMMAND="myLocalHistory" # we don't need everything within the history alias
by albertzeyer 7y ago
It's a very custom solution.
For Bash, in ~/.bashrc:
export PROMPT_COMMAND="myLocalHistory"
# we don't need everything within the history
alias useHistory='grep -E -v "^ls$|^ll$|^l$|^dir$|^cd |^bg$|^fg$|^qstat |^note |^mutt|^std|^clear$|^qinfo$|^gh|^qw$" | wc -l'
function myLocalHistory()
{
HISTORYLINE=`history | tail -1 | sed 's:^ *[0-9]* *::g'`
if [ `echo $HISTORYLINE | useHistory` == 1 ] ; then
((date +%F.%H-%M-%S | tr -d '\n' ; echo " $HISTORYLINE") >>.history.$USER) 2>/dev/null
fi
}
For ZSH, in ~/.zshrc:
preexec () {
~/dotfiles/system-tools/helpers/local-history-add.py $1 >/dev/null
}
For Fish, in ~/.config/fish/config.fish:
function fish_preexec --on-event fish_preexec
~/dotfiles/system-tools/helpers/local-history-add.py $argv &
end
The script local-history-add.py is here: https://github.com/albertz/helpers/blob/master/local-history-add.py https://github.com/albertz/helpers/blob/master/local-history...
The Bash solution probably could also be simplified by using this script, which takes care of filtering logic and adding it to the history file, in your preferred format.