Skip to content

Instantly share code, notes, and snippets.

@neilberget
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neilberget/1588f136847ed40afcd4 to your computer and use it in GitHub Desktop.
Save neilberget/1588f136847ed40afcd4 to your computer and use it in GitHub Desktop.
Selecta Aliases
# Kill a process
alias zap="ps aux | tail -n+2 | selecta | tr -s ' ' | cut -d ' ' -f 2 | xargs kill"
# Kill a process with -9
alias zap9="ps aux | tail -n+2 | selecta | tr -s ' ' | cut -d ' ' -f 2 | xargs kill -9"
# cd into an arbitrarily deep subdirectory. Don't try in directories with too many subdirectories (e.g. $HOME)
alias sd='cd $(find * -type d | selecta)'
# Create a ~/.sshto file with a list of hosts (or user@hosts) you commonly ssh to.
alias sshto='ssh $(selecta < ~/.sshto)'
# Docker shortcuts
alias dpicker="docker ps | tail -n+2 | selecta | cut -d' ' -f1"
alias dstop="dpicker | xargs docker rm -f"
alias dtail="dpicker | xargs docker logs -f"
alias dtop="dpicker | xargs docker top"
alias dinspect="dpicker | xargs docker inspect"
# Run a make target
maketargets() {
make -qp | awk -F':' '/^[a-zA-Z0-9][^$#\/\t=]*:([^=]|$)/ {split($1,A,/ /);for(i in A)print A[i]}'
}
alias makes="maketargets | selecta | xargs make"
# Run a single spec file
alias spec1="find spec -type f | selecta | xargs bundle exec rspec"
@neilberget
Copy link
Author

Selecta is a pretty useful command line utility for fuzzy selecting from a list.

This is my list of aliases that use selecta.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment