Skip to content

Commit

Permalink
Wrote history helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
Lissy93 committed Aug 11, 2024
1 parent 6acb6b4 commit 31cd172
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions config/zsh/aliases/general.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ if alias_not_used i; then; alias i='id'; fi
if alias_not_used j; then; alias j='jobs'; fi
if alias_not_used l; then; alias l='ls'; fi
if alias_not_used m; then; alias m='man'; fi
if alias_not_used n; then; alias m='nc'; fi
if alias_not_used p; then; alias p='pwd'; fi
if alias_not_used s; then; alias s='sudo'; fi
if alias_not_used t; then; alias t='touch'; fi
Expand Down Expand Up @@ -120,6 +121,18 @@ alias h-search='fc -El 0 | grep' # Searchses for a word in terminal history
alias top-history='history 0 | awk '{print $2}' | sort | uniq -c | sort -n -r | head'
alias histrg='history -500 | rg' # Rip grep search recent history

# Fuzzy search through command history with Ctrl+R
if [[ ! "$terminfo[kcuu1]" ]]; then
bindkey '^R' fzf-history-widget
fi

fzf-history-widget() {
local selected_command=$(fc -rl 1 | fzf --height 40% --reverse --tac | sed -E 's/ *[0-9]+\*? +//')
LBUFFER="$selected_command"
zle redisplay
}
zle -N fzf-history-widget

# Clearing terminal
if command_exists hr ; then
alias c='clear && hr_color='\033[0;37m' && hr'
Expand Down

0 comments on commit 31cd172

Please sign in to comment.