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 aws1='ssh ubuntu@ec2-18-196-102-236.eu-central-1.compute.amazonaws.com'
|
||||||
alias gcp='gcloud compute ssh instance-1'
|
alias gcp='gcloud compute ssh instance-1'
|
||||||
alias blist='borg list ssh://borg@docker1.home.hartzan.com:2222/backup/arch'
|
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'
|
||||||
|
|
||||||
|
|
|
||||||
1
.zshrc
1
.zshrc
|
|
@ -111,6 +111,7 @@ export BROWSER=/usr/bin/google-chrome-stable
|
||||||
#fzf
|
#fzf
|
||||||
export FZF_CTRL_R_OPTS='--sort --exact'
|
export FZF_CTRL_R_OPTS='--sort --exact'
|
||||||
export FZF_ALT_C_OPTS="--preview 'tree -C {} | head -200'"
|
export FZF_ALT_C_OPTS="--preview 'tree -C {} | head -200'"
|
||||||
|
export FZF_DEFAULT_COMMAND='fd --type f --hidden'
|
||||||
|
|
||||||
# Compilation flags
|
# Compilation flags
|
||||||
export ARCHFLAGS="-arch x86_64"
|
export ARCHFLAGS="-arch x86_64"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue