Created
July 5, 2019 12:43
-
-
Save dpastoor/0e72334c39f14b1b54b0456ab882718f to your computer and use it in GitHub Desktop.
fish snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# from https://medium.com/@sidneyliebrand/how-fzf-and-ripgrep-improved-my-workflow-61c7ca212861 | |
function fp --description 'Search your $PATH' | |
set -l loc (echo $PATH | tr ' ' '\n' | eval "fzf $FZF_DEFAULT_OPTS --header='[find:path]'") | |
if test (count $loc) = 1 | |
set -l cmd (rg --files -L $loc | rev | cut -d'/' -f1 | rev | tr ' ' '\n' | eval "fzf $FZF_DEFAULT_OPTS --header='[find:exe] => $loc'") | |
if test (count $cmd) = 1 | |
echo $cmd | |
else | |
fp | |
end | |
end | |
end | |
function kp --description "Kill processes" | |
set -l __kp__pid '' | |
if contains -- '--tcp' $argv | |
set __kp__pid (lsof -Pwni tcp | sed 1d | eval "fzf $FZF_DEFAULT_OPTS -m --header='[kill:tcp]'" | awk '{print $2}') | |
else | |
set __kp__pid (ps -ef | sed 1d | eval "fzf $FZF_DEFAULT_OPTS -m --header='[kill:process]'" | awk '{print $2}') | |
end | |
if test "x$__kp__pid" != "x" | |
if test "x$argv[1]" != "x" | |
echo $__kp__pid | xargs kill $argv[1] | |
else | |
echo $__kp__pid | xargs kill -9 | |
end | |
kp | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment