Skip to content

Instantly share code, notes, and snippets.

@kovacshuni
Forked from tamas-molnar/fleetctl-shortcuts
Created August 3, 2016 11:33
Show Gist options
  • Save kovacshuni/b2d5ef3194f245c72b3c274a72db7b8a to your computer and use it in GitHub Desktop.
Save kovacshuni/b2d5ef3194f245c72b3c274a72db7b8a to your computer and use it in GitHub Desktop.
aliases and shortcuts
alias fc='fleetctl'
alias fclm='fleetctl list-machines'
alias fclu='fleetctl list-units'
alias fcjf='fleetctl journal -f '
alias fcbad='fleetctl list-units | grep -v "exited\|running\|backup\|upgrade"'
function fclmg() { fleetctl list-machines | grep $@ ;}
function fclug() { fleetctl list-units | grep $@ ;}
function fcssh() { fleetctl ssh $@ ;}
function fcjfl() { fleetctl journal -f --lines=$@ ; }
function fcres() { fleetctl ssh $@ sudo systemctl restart $@ ; }
Add autocomplete functionality for some of the above functions:
Generate your list of services in a file on one line, separated by spaces: ~/services.list
Create file services_autocomplete.sh:
_services(){
local cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $(compgen -W "$(<~/services.list)" -- ${cur}) )
}
complete -F _services fcres
complete -F _services fcjf
complete -F _services fcssh
Source file in your .bashrc
. ~/services_autocomplete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment