fish: functions: Check return result of fzf selection

This commit is contained in:
Sanchayan Maity 2022-12-26 14:46:31 +05:30
parent 3279c97814
commit 7310c77f78
Signed by: sanchayanmaity
GPG key ID: 6F6A0609C12038F3
10 changed files with 30 additions and 10 deletions

View file

@ -1,4 +1,6 @@
function cdG --description 'Select a coredump to run coredumpctl gdb'
coredumpctl list --reverse | awk -F" " '$9 == "present"' | fzf | read -l result
if test -n "$result"
coredumpctl gdb (echo $result | awk -F" " '{print $5}')
end
end

View file

@ -1,4 +1,6 @@
function cdi --description 'Select a coredump to run coredumpctl info'
coredumpctl list --reverse | awk -F" " '$9 == "present"' | fzf | read -l result
if test -n "$result"
coredumpctl info (echo $result | awk -F" " '{print $5}')
end
end

View file

@ -1,4 +1,6 @@
function pfr --description 'Select a process to record performance data in given file name'
set proc (ps -ef | fzf | awk '{print $2}')
if test -n "$proc"
perf record -F 99 -o $argv -p $proc
end
end

View file

@ -1,4 +1,6 @@
function pft --description 'Select a process to run perf top'
set proc (ps -ef | fzf | awk '{print $2}')
if test -n "$proc"
perf top -p $proc
end
end

View file

@ -1,4 +1,6 @@
function pk --description 'Fuzzy find a process to kill'
set proc (ps -ef | fzf | awk '{print $2}')
if test -n "$proc"
kill -SIGKILL $proc
end
end

View file

@ -1,4 +1,6 @@
function psmem --description 'Show memory usage of a process'
set proc (ps -ef | fzf | awk '{print $2}')
if test -n "$proc"
ps_mem -p $proc
end
end

View file

@ -1,4 +1,6 @@
function pst --description 'Show process tree of a process'
set proc (ps -ef | fzf | awk '{print $2}' | head -1)
if test -n "$proc"
pstree -H $proc $proc
end
end

View file

@ -1,6 +1,8 @@
function rfc --description 'Search for string in RFC documents and open'
if test -e ~/rfc
rg --files-with-matches $argv ~/rfc | fzf --preview='less {}' | read -l result
if test -n "$result"
nvim -R $result
end
end
end

View file

@ -1,4 +1,6 @@
function ta --description 'Attaches to a selected session'
set session (tmux list-sessions | fzf | awk -F':' '{print $1}')
if test -n "$session"
tmux attach -t $session
end
end

View file

@ -1,4 +1,6 @@
function topf --description 'Select a process to run top'
set proc (ps -ef | fzf | awk '{print $2}')
if test -n "$proc"
top -H -p $proc
end
end