home | added bash_complition for doas

This commit is contained in:
Don Harper 2023-09-23 17:20:44 -05:00
parent 846d32d0eb
commit 6768888ec2
2 changed files with 54 additions and 3 deletions

50
home/bash_complition.nix Normal file
View file

@ -0,0 +1,50 @@
{ pkgs, ... }: {
home.file = {
doascomplete = {
enable = true;
target = ".bash_completion.d/doas.sh";
text = ''
_doas()
{
local cur prev words cword split
_init_completion -s || return
local i mode=normal
[[ ''$1 == *doasedit ]] && mode=edit
[[ ''$mode == normal ]] &&
for ((i = 1; i <= cword; i++)); do
if [[ ''${words[i]} != -* ]]; then
local PATH=''$PATH:/sbin:/usr/sbin:/usr/local/sbin
local root_command=''${words[i]}
_command_offset ''$i
return
fi
[[ ''${words[i]} == -@(!(-*)[uUgCp]) ]] &&
((i++))
done
case "''$prev" in
-u)
COMPREPLY=(''$(compgen -u -- "''$cur"))
return
;;
esac
''$split && return
if [[ ''$cur == -* ]]; then
local opts=''$(_parse_help "''$1")
COMPREPLY=(''$(compgen -W ''${opts:-''$(_parse_usage "''$1")}' -- "''$cur"))
[[ ''${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
if [[ ''$mode == edit ]]; then
_filedir
fi
} &&
complete -F _doas doas
'';
};
};
}

View file

@ -1,12 +1,13 @@
{ config, pkgs, ... }:
{
imports = [
./tmux.nix
./neovim.nix
./khard.nix
./bash_complition.nix
./khal.nix
./khard.nix
./liquidprompt.nix
./neovim.nix
./newsboat.nix
./tmux.nix
./vifm.nix
];
home.packages = with pkgs; [