Skip to content

Commit

Permalink
ahoy fish completion
Browse files Browse the repository at this point in the history
  • Loading branch information
hanoii committed Apr 3, 2024
1 parent c2346ac commit c7b8719
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .ddev/addon-metadata/pimp-my-shell/manifest.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: pimp-my-shell
repository: .
version: ""
install_date: "2024-04-01T19:41:31-03:00"
install_date: "2024-04-03T10:04:10-03:00"
project_files:
- web-build/Dockerfile.pimp-my-shell
- homeadditions/.bashrc.d/pimp-my-shell.sh
Expand All @@ -10,6 +10,7 @@ project_files:
- commands/web/gum
- commands/host/fish
- homeadditions/.local/share/bash-completion/completions/ahoy
- homeadditions/.local/share/fish/vendor_completions.d/ahoy.fish
- homeadditions/.config/starship.toml
- homeadditions/.config/fish/conf.d/z.fish
- pimp-my-shell/hooks/README.md
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#ddev-generated

# @TODO: Try to use ahoy -f as part of the commands so autocomplete works with that
# was playing with `ahoy --help | sed -z 's/.*COMMANDS:\(.*\)GLOBAL.*/\1/' | cut -d ' ' -f 4'`
# to extract commands instead of --generate-bash-completion but needs more work
# apparently argparse can be used to extract the file parameter.

function __fish_ahoy_subcommand
set -l cmd (commandline)
eval $cmd --generate-bash-completion | grep -vw h | grep -vw help
end

function __fish_ahoy_config
set -l cmd (commandline -ct)
echo "cmd: $cmd" >> debug.txt
set -l dirglob ""
set -l dirfind "."
if test -d (string replace -r '(.*)/[^\/]*$' '$1/' $cmd)
set dirglob (string replace -r '(.*)/[^\/]*$' '$1/' $cmd)
set dirfind (string replace -r '(.*)/[^\/]*$' '$1/' $cmd)
end
set -l configs $dirglob.*.yml $dirglob.*.yaml $dirglob.*.yml $dirglob*.yaml
for i in $configs
echo $i
end
find $dirfind -mindepth 1 -maxdepth 1 -type d | sed 's/\.\/\(.*\)/\1/g' | sed 's/$/\//g' | sort
end

complete -c ahoy -f
complete -c ahoy -n "not __fish_seen_subcommand_from (ahoy --generate-bash-completion)" -a "(ahoy --generate-bash-completion)"
complete -c ahoy -n "__fish_seen_subcommand_from (ahoy -h | grep ▼ | cut -d ' ' -f 4)" -a "(__fish_ahoy_subcommand)"
complete -c ahoy -s f -l file -x -a "(__fish_ahoy_config)"
32 changes: 32 additions & 0 deletions homeadditions/.local/share/fish/vendor_completions.d/ahoy.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#ddev-generated

# @TODO: Try to use ahoy -f as part of the commands so autocomplete works with that
# was playing with `ahoy --help | sed -z 's/.*COMMANDS:\(.*\)GLOBAL.*/\1/' | cut -d ' ' -f 4'`
# to extract commands instead of --generate-bash-completion but needs more work
# apparently argparse can be used to extract the file parameter.

function __fish_ahoy_subcommand
set -l cmd (commandline)
eval $cmd --generate-bash-completion | grep -vw h | grep -vw help
end

function __fish_ahoy_config
set -l cmd (commandline -ct)
echo "cmd: $cmd" >> debug.txt
set -l dirglob ""
set -l dirfind "."
if test -d (string replace -r '(.*)/[^\/]*$' '$1/' $cmd)
set dirglob (string replace -r '(.*)/[^\/]*$' '$1/' $cmd)
set dirfind (string replace -r '(.*)/[^\/]*$' '$1/' $cmd)
end
set -l configs $dirglob.*.yml $dirglob.*.yaml $dirglob.*.yml $dirglob*.yaml
for i in $configs
echo $i
end
find $dirfind -mindepth 1 -maxdepth 1 -type d | sed 's/\.\/\(.*\)/\1/g' | sed 's/$/\//g' | sort
end

complete -c ahoy -f
complete -c ahoy -n "not __fish_seen_subcommand_from (ahoy --generate-bash-completion)" -a "(ahoy --generate-bash-completion)"
complete -c ahoy -n "__fish_seen_subcommand_from (ahoy -h | grep ▼ | cut -d ' ' -f 4)" -a "(__fish_ahoy_subcommand)"
complete -c ahoy -s f -l file -x -a "(__fish_ahoy_config)"
1 change: 1 addition & 0 deletions install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ project_files:
- commands/web/gum
- commands/host/fish
- homeadditions/.local/share/bash-completion/completions/ahoy
- homeadditions/.local/share/fish/vendor_completions.d/ahoy.fish
- homeadditions/.config/starship.toml
- homeadditions/.config/fish/conf.d/z.fish
- pimp-my-shell/hooks/README.md
Expand Down

0 comments on commit c7b8719

Please sign in to comment.