sh: Added date stamps to history command

Prepending history with datestamps (which are already correctly saved in
my shell history), so I know WHEN I last run a command (roughly) and can
also search for the dates using `fzfhistory`.
This commit is contained in:
Marty Oehme 2021-03-27 22:19:43 +01:00
parent e2b82b56f9
commit ebdfb17bb1
Signed by: Marty
GPG Key ID: B7538B8F50A1C800
2 changed files with 38 additions and 38 deletions

View File

@ -49,7 +49,7 @@ alias myip="curl -s icanhazip.com"
# fzf
if exist fzf; then
# Display fuzzy-searchable history
alias fzfhistory="history 0 | fzf --tac --height 20"
alias fzfhistory="history -l -E -D 0 | fzf --tac --height 20"
fzfman() {
man "$(apropos --long "$1" | fzf | awk '{print $2, $1}' | tr -d '()')"
}

View File

@ -27,16 +27,16 @@ unset PLUG_FOLDER
# simple fzf-tab settings
FZF_TAB_COMMAND=(
fzf
--ansi # Enable ANSI color support, necessary for showing groups
--expect='$continuous_trigger,$print_query' # For continuous completion and print query
'--color=hl:$(( $#headers == 0 ? 108 : 255 ))'
--nth=2,3 --delimiter='\x00' # Don't search prefix
--layout=reverse --height='${FZF_TMUX_HEIGHT:=75%}'
--tiebreak=begin -m --bind=tab:down,btab:up,change:top,ctrl-space:toggle --cycle
'--query=$query' # $query will be expanded to query string at runtime.
'--header-lines=$#headers' # $#headers will be expanded to lines of headers at runtime
--print-query
fzf
--ansi # Enable ANSI color support, necessary for showing groups
--expect='$continuous_trigger,$print_query' # For continuous completion and print query
'--color=hl:$(( $#headers == 0 ? 108 : 255 ))'
--nth=2,3 --delimiter='\x00' # Don't search prefix
--layout=reverse --height='${FZF_TMUX_HEIGHT:=75%}'
--tiebreak=begin -m --bind=tab:down,btab:up,change:top,ctrl-space:toggle --cycle
'--query=$query' # $query will be expanded to query string at runtime.
'--header-lines=$#headers' # $#headers will be expanded to lines of headers at runtime
--print-query
)
zstyle ':fzf-tab:*' command $FZF_TAB_COMMAND
# format colorful groups for different completion actions
@ -76,16 +76,16 @@ PROMPT=" $PROMPT"
[ -f "$CONFDIR/sh/alias" ] && source "$CONFDIR/sh/alias"
# load additional aliases
if [ -d "$CONFDIR/sh/alias.d" ]; then
for _alias in "$CONFDIR/sh/alias.d"/*.sh; do
. "$_alias"
done
unset _alias
for _alias in "$CONFDIR/sh/alias.d"/*.sh; do
. "$_alias"
done
unset _alias
fi
if [ -d "$ZSHCONFDIR/alias.d" ]; then
for _alias in "$ZSHCONFDIR/alias.d"/*.sh; do
. "$_alias"
done
unset _alias
for _alias in "$ZSHCONFDIR/alias.d"/*.sh; do
. "$_alias"
done
unset _alias
fi
# Correct spelling for commands
@ -105,16 +105,16 @@ zstyle ':completion:*' cache-path "${XDG_CACHE_HOME:-$HOME/.cache}/zshcompcache"
### history
## Set ZSH History defaults
setopt append_history
setopt extended_history
setopt hist_expire_dups_first
setopt hist_ignore_all_dups
setopt extended_history # record command start time
setopt hist_ignore_dups
setopt hist_ignore_all_dups # do not put duplicated command into history list
setopt hist_save_no_dups # do not save duplicated command
setopt hist_expire_dups_first
setopt hist_ignore_space
setopt hist_reduce_blanks
setopt hist_save_no_dups
setopt hist_reduce_blanks # remove unnecessary blanks
setopt hist_verify
# Share your history across all your terminal windows
setopt share_history
setopt inc_append_history_time # append command to history file immediately after execution
setopt share_history # Share your history across all your terminal windows
setopt pushd_ignore_dups
#setopt pushd_silent
export HISTSIZE=100000
@ -125,7 +125,7 @@ export HISTIGNORE="ls:cd:cd -:pwd:exit:date:* --help"
## Set ZSH History aliases
# Show the top 5 commands used in recent history
history_top() {
history | awk "{a[\$2]++} END{for(i in a){printf \"%5d\t%s\n\",a[i],i}}" | sort -rn | head
history | awk "{a[\$2]++} END{for(i in a){printf \"%5d\t%s\n\",a[i],i}}" | sort -rn | head
}
# Display timestamped recent command history
alias history="fc -l -d -D"
@ -133,11 +133,11 @@ alias history="fc -l -d -D"
### Glob Alias expansion
# Expand aliases inline - see http://blog.patshead.com/2012/11/automatically-expaning-zsh-global-aliases---simplified.html
globalias() {
if [[ $LBUFFER =~ [A-Z0-9]+$ ]]; then
zle _expand_alias
zle expand-word
fi
zle self-insert
if [[ $LBUFFER =~ [A-Z0-9]+$ ]]; then
zle _expand_alias
zle expand-word
fi
zle self-insert
}
zle -N globalias
bindkey " " globalias
@ -182,16 +182,16 @@ bindkey -M vicmd '^e' edit-command-line
# Deduplicate PATH - remove any duplicate entries from PATH
# from: https://unix.stackexchange.com/questions/40749/remove-duplicate-path-entries-with-awk-command
get_var() {
eval 'printf "%s\n" "${'"$1"'}"'
eval 'printf "%s\n" "${'"$1"'}"'
}
set_var() {
eval "$1=\"\$2\""
eval "$1=\"\$2\""
}
dedup_pathvar() {
pathvar_name="$1"
pathvar_value="$(get_var "$pathvar_name")"
deduped_path="$(perl -e 'print join(":",grep { not $seen{$_}++ } split(/:/, $ARGV[0]))' "$pathvar_value")"
set_var "$pathvar_name" "$deduped_path"
pathvar_name="$1"
pathvar_value="$(get_var "$pathvar_name")"
deduped_path="$(perl -e 'print join(":",grep { not $seen{$_}++ } split(/:/, $ARGV[0]))' "$pathvar_value")"
set_var "$pathvar_name" "$deduped_path"
}
dedup_pathvar PATH
dedup_pathvar MANPATH