brain: add bash-completion

This commit is contained in:
tv 2023-08-01 13:17:30 +02:00
parent 7be9bfdc55
commit f091cd5e03

View File

@ -1,4 +1,4 @@
{ pass, write, writeDash, ... }:
{ pass, runCommand, write, writeDash, ... }:
write "brain" {
"/bin/brain".link = writeDash "brain" ''
@ -9,4 +9,14 @@ write "brain" {
PASSWORD_STORE_DIR=$HOME/brain \
exec ${pass}/bin/passmenu $@
'';
"/share/bash-completion/completions/brain".link =
runCommand "brain-completions" {
} /* sh */ ''
sed -r '
s/\<_pass?(_|\>)/_brain\1/g
s/\<__password_store/_brain/g
s/\<pass\>/brain/
s/\$HOME\/\.password-store/$HOME\/brain/
' < ${pass}/share/bash-completion/completions/pass > $out
'';
}