As a developer, I spend a lot of time on command line and since I found fzf, a command line fuzzy finder, I find my productivity has been improved tremendously by applying fzf in everday commands that I use. Below is the collection of small fzf snippets that I wrote and use a lot myself.
fignore: Download .gitignore
Usage
Source
|
|
github/gitignore contains a good collection of .gitignore
template. This script uses github tree api to list all the files ending with .gitignore from that github repository and downloads selected file as .gitignore
in the current directory.
fnpm: Run npm script
Usage
Source
|
|
This script looks into current folder package.json
, extract all the npm script names using jq
and pipe those names to fzf for interactive selection. The selected script name will be run using npm run
.
fsb: Switch git branch
Usage
Source
|
|
This script takes in an optional pattern to search available git branches. If a branch matches the pattern, it will checkout that branch. There’s an additional handling for case where the branch only exists in remote but not yet checked out to local. In that case this script will checkout that remote branch to a local branch.
zf: Switch directory
Usage
Source
|
|
This script makes use of (fasd)[https://github.com/clvv/fasd] to interactively switch to a commonly-accessed directory. fasd
itself already provides fasd -sid
command (or sd
if you use its default aliases), however I find it a little bit easier to use fzf
to select, instead of typing sequence number provided by sd
.
Android emulator - related
droidsa: Start Android Emulator
|
|
This alias uses avdmanager
to list available avd
and starts android emulator with that avd
droidrm: Uninstall a program in the current emulator/device
|
|
This alias lists user installed programs in the current emulator/device to uninstall
Kubernetes - related
fkrm: Delete Kubernetes resource in current namespace
Usage
Source
|
|
The script takes in resource type (pod, deployment, service, etc) as 1st parameter and interactly select the resource to delete using fzf
fkl: Get log of a container in current namespace
Usage
Source
|
|
This script asks to select the pod which contains the container to get logs first. If the pod only has one container, it straight away gives the logs of that container (-0
option for parameter), otherwise it asks again for the container to retrieve logs.