diff --git a/home/bash_complition.nix b/home/bash_complition.nix new file mode 100644 index 0000000..3385b7f --- /dev/null +++ b/home/bash_complition.nix @@ -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 + ''; + }; + }; +} diff --git a/home/packages-cli.nix b/home/packages-cli.nix index 0ecd767..37e34d8 100644 --- a/home/packages-cli.nix +++ b/home/packages-cli.nix @@ -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; [