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