Last active
July 5, 2024 08:28
-
-
Save cschindlbeck/db0ac894a46aac42861e96437d8ed763 to your computer and use it in GitHub Desktop.
This file contains 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
##################################### | |
# Useful commands that leverage fzf # | |
##################################### | |
# Fuzzy file open: Type ff and find file via fzf and open in nvim | |
ff() { nvim "$(find . -type f | fzf)"; } | |
# Fuzzy cd: Type fcd and select folder via fzf | |
fcd() { cd "$(find . -type d | fzf)"; } | |
# Fuzzy git branch checkout: Type fgc and select branch via fzf | |
fgc() { git switch "$(git branch -v | fzf | awk '{print $1}')"; } | |
# Fuzzy git add: Type fga and select file via fzf | |
fga() { git add "$(git status --porcelain | fzf | awk '{print $2}')"; } | |
# Fuzzy process killer | |
fpkill() { | |
local selection | |
selection=$(ps -e -o pid,comm | fzf) | |
local pid=$(echo "$selection" | awk '{print $1}') | |
local pname=$(echo "$selection" | awk '{print $2}') | |
if [ "$pid" != "" ]; then | |
kill -9 "$pid" > /dev/null 2>&1 && echo "Process $pname (PID $pid) has been successfully killed." | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment