3 ms·
Can you share how you do this please?
by oarsinsync 7y ago
Can you share how you do this please?
- danShumway 7y agoNot GP, and my setup is a great deal less sophisticated than GP's. However, in my `.bashrc`, I have: log_bash_persistent_history() { [[ $(history 1) =~ ^\ *[0-9]+\ +([^\ ]+\ [^\ ]+)\ +(.*)$ ]] local date_part="${BASH_REMATCH[1]}" local command_part="${BASH_REMATCH[2]}" if [ "$command_part" != "$PERSISTENT_HISTORY_LAST" ] then echo $date_part "|" "$command_part" >> ~/.persistent_history export PERSISTENT_HISTORY_LAST="$command_part" fi } # Stuff to do on PROMPT_COMMAND run_on_prompt_command() { log_bash_persistent_history } PROMPT_COMMAND="run_on_prompt_command" HISTTIMEFORMAT="%d/%m/%y %T " alias phgrep='cat ~/.persistent_history|grep --color' alias hgrep='history|grep --color' This doesn't save all of the information like the current shell, working directory, etc... but you could easily modify it to include that information. It also doesn't do all of the context-aware piping, you have to rely on grep. But just having a really good persistent history is itself insanely useful. My setup was itself stolen from someone else on HN a few years ago, and I've since forgotten their name.
- mic47 7y agoIf you want to have just persistent histry (really simple), you can use vanilla bash history something like. export HISTCONTROL=ignorespace shopt -s histappend export HISTSIZE=99999999 # Big enough number to never rotate history (or when you really don't care) export HISTFILESIZE=99999999 shopt -s checkwinsize export HISTTIMEFORMAT='%F %T '
- mic47 7y agoSure, it's all here in my rc files repo, though scattered in this repo https://github.com/mic47/linux-configuration https://github.com/mic47/linux-configuration Here are pointers: This install fzf into your bash, and apply small patch on fzf scripts to use bash history: https://github.com/mic47/linux-configuration/blob/master/scripts/install.sh#L18-L24 https://github.com/mic47/linux-configuration/blob/master/scr... Some more fzf stuff to put into your bashrc: https://github.com/mic47/linux-configuration/blob/master/bashrc#L211-L236 https://github.com/mic47/linux-configuration/blob/master/bas... This is .super_history setup: https://github.com/mic47/linux-configuration/blob/master/bash/history.sh https://github.com/mic47/linux-configuration/blob/master/bas... https://github.com/mic47/linux-configuration/blob/master/bashrc#L22-L37 https://github.com/mic47/linux-configuration/blob/master/bas... This reminds me that I should probably modularize my setup.