playing with fzf, created few functions
This commit is contained in:
parent
cdd1d31a75
commit
3d92c7caee
48
.zsh_aliases
48
.zsh_aliases
|
|
@ -15,3 +15,51 @@ alias edis='expressvpn disconnect'
|
|||
alias aws1='ssh ubuntu@ec2-18-196-102-236.eu-central-1.compute.amazonaws.com'
|
||||
alias gcp='gcloud compute ssh instance-1'
|
||||
alias blist='borg list ssh://borg@docker1.home.hartzan.com:2222/backup/arch'
|
||||
|
||||
fzf_find_edit() {
|
||||
local file=$(
|
||||
fzf --no-multi --preview 'bat --color=always --line-range :500 {}'
|
||||
)
|
||||
if [[ -n $file ]]; then
|
||||
$EDITOR $file
|
||||
fi
|
||||
}
|
||||
|
||||
alias ffe='fzf_find_edit'
|
||||
|
||||
fda() {
|
||||
local dir
|
||||
dir=$(find ${1:-.} -type d 2> /dev/null | fzf +m) && cd "$dir"
|
||||
}
|
||||
|
||||
alias fcd='fda'
|
||||
|
||||
fzf_grep_edit(){
|
||||
if [[ $# == 0 ]]; then
|
||||
echo 'Error: search term was not provided.'
|
||||
return
|
||||
fi
|
||||
local match=$(
|
||||
rg --color=never --line-number "$1" |
|
||||
fzf --no-multi --delimiter : \
|
||||
--preview "bat --color=always --line-range {2}: {1}"
|
||||
)
|
||||
local file=$(echo "$match" | cut -d':' -f1)
|
||||
if [[ -n $file ]]; then
|
||||
$EDITOR $file +$(echo "$match" | cut -d':' -f2)
|
||||
fi
|
||||
}
|
||||
|
||||
alias fge='fzf_grep_edit'
|
||||
|
||||
fzf_kill() {
|
||||
local pids=$(
|
||||
ps -f -u $USER | sed 1d | fzf --multi | tr -s [:blank:] | cut -d' ' -f3
|
||||
)
|
||||
if [[ -n $pids ]]; then
|
||||
echo "$pids" | xargs kill -9 "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
alias fkill='fzf_kill'
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue