diff options
author | tdro <tdro@users.noreply.github.com> | 2022-03-18 13:58:56 -0400 |
---|---|---|
committer | tdro <tdro@users.noreply.github.com> | 2022-03-18 14:05:43 -0400 |
commit | d60564519cb4fab19dbf270dd7696052990fcfe1 (patch) | |
tree | e5b71478284050f5ad3715d6561f2dba78f11902 /.local | |
parent | d8f916b6fe986a2974620d4386ec50de08f9d938 (diff) | |
download | dotfiles-d60564519cb4fab19dbf270dd7696052990fcfe1.tar.gz dotfiles-d60564519cb4fab19dbf270dd7696052990fcfe1.tar.bz2 dotfiles-d60564519cb4fab19dbf270dd7696052990fcfe1.zip |
.bash_profile: Fix history with real persist
Use custom fzf completion and bindings.
Diffstat (limited to '.local')
-rwxr-xr-x | .local/bin/bashhistory | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/.local/bin/bashhistory b/.local/bin/bashhistory new file mode 100755 index 0000000..6320834 --- /dev/null +++ b/.local/bin/bashhistory @@ -0,0 +1,31 @@ +#!/bin/sh -eu + +directory="$XDG_DATA_HOME/bash" +persist="$directory/history" +default="$HOME/.bash_history" +current="$HISTFILE" + +_prune() { + sed --in-place '/^#/d' "$1" && # Remove all timestamps. + sed --in-place '/......../!d' "$1" && # Remove all commands 8 characters or less. + sort --unique "$1" | sponge "$1" # Remove all duplicate entries. +} + +mkdir --parents "$directory" +touch "$current" + +_migrate() { + [ -f "$default" ] && + cat "$default" >>"$persist" && + _prune "$persist" && + rm "$default" +} + +_store() { + cat "$current" >> "$persist" && + _prune "$persist" && + true > "$current" +} + +_migrate || true +_store |