I have a simple alias to copy passwords to the clipboard.
alias cpass='pass -c "$@"'
Pretty straight forward; however, I lose auto-complete which makes this alias pretty pointless. To fix this, I simply append the following to ~/.bashrc
# Autocomplete 'cpass'
_completion_loader pass
complete -F _pass cpass
Bash only loads an appropriate auto-complete function when the program is acted upon (e.g. entering pass <tab>
) so we need to explicitly load the function for pass
with _completion_loader pass
. We then assign cpass
the explicitly loaded function with complete -F _pass cpass
.
That's it! Feel free to use this for any of your aliases. You can find almost all auto-complete functions in /usr/share/bash-completion/completions/
.
Cheers!
Tom is the founder of Astral TableTop. He's a homebrewer, hiker, and has an about page. Follow @tlackemann on Twitter for more discussions like this.