From 005b2ed850f8e31b05fbfe78264d9024d0eb1e74 Mon Sep 17 00:00:00 2001 From: Xevion Date: Tue, 30 Dec 2025 00:26:22 -0600 Subject: [PATCH] feat: add Fish function wrappers for copilot suggest/explain commands Replace gh copilot aliases with custom Fish functions that provide better help text and wrap the copilot CLI with appropriate prompts --- home/.chezmoitemplates/nushell/config.nu.tmpl | 4 +-- home/dot_config/fish/conf.d/abbr.fish.tmpl | 3 +- home/dot_config/fish/functions/chai.fish.tmpl | 2 +- home/dot_config/fish/functions/explain.fish | 28 ++++++++++++++++ home/dot_config/fish/functions/ghce.fish | 3 ++ home/dot_config/fish/functions/ghcs.fish | 3 ++ home/dot_config/fish/functions/suggest.fish | 32 +++++++++++++++++++ home/executable_dot_bash_aliases.tmpl | 4 +-- 8 files changed, 72 insertions(+), 7 deletions(-) create mode 100644 home/dot_config/fish/functions/explain.fish create mode 100644 home/dot_config/fish/functions/ghce.fish create mode 100644 home/dot_config/fish/functions/ghcs.fish create mode 100644 home/dot_config/fish/functions/suggest.fish diff --git a/home/.chezmoitemplates/nushell/config.nu.tmpl b/home/.chezmoitemplates/nushell/config.nu.tmpl index 05be0d7..5ca5665 100644 --- a/home/.chezmoitemplates/nushell/config.nu.tmpl +++ b/home/.chezmoitemplates/nushell/config.nu.tmpl @@ -949,8 +949,8 @@ alias romanlog = ssh roman 'tail -F /var/log/syslog' --lines 100 # Other aliases alias gpt = chatgpt -alias copilot = gh copilot -alias suggest = gh copilot suggest -t shell +alias copilot = copilot +alias suggest = copilot -p "suggest:" --allow-all-tools alias spt = spotify_player {{ if eq .chezmoi.os "linux" }} alias mousefix = sudo udevadm trigger diff --git a/home/dot_config/fish/conf.d/abbr.fish.tmpl b/home/dot_config/fish/conf.d/abbr.fish.tmpl index 51d0795..a7391fa 100644 --- a/home/dot_config/fish/conf.d/abbr.fish.tmpl +++ b/home/dot_config/fish/conf.d/abbr.fish.tmpl @@ -48,8 +48,7 @@ abbr -a copeh 'claude --model haiku' abbr -a hcope 'claude --model haiku' abbr -a gpt 'chatgpt' abbr -a share 'share.ts' -abbr -a copilot 'gh copilot' -abbr -a suggest 'gh copilot suggest -t shell' +abbr -a copilot 'copilot' abbr -a spt 'spotify_player' abbr -a gitalias 'alias | grep "git "' abbr -a mousefix 'sudo udevadm trigger' diff --git a/home/dot_config/fish/functions/chai.fish.tmpl b/home/dot_config/fish/functions/chai.fish.tmpl index 8af47ce..5f7b56e 100644 --- a/home/dot_config/fish/functions/chai.fish.tmpl +++ b/home/dot_config/fish/functions/chai.fish.tmpl @@ -23,7 +23,7 @@ function chai --description "Interactive chezmoi apply with fzf diff preview" --with-nth=4 \ --nth=1 \ --prompt='Apply Changes > ' \ - --preview='chezmoi diff {1} 2>/dev/null | bat -pp --color=always --language=diff' \ + --preview='chezmoi diff ~/{1} 2>/dev/null | bat -pp --color=always --language=diff' \ --preview-window=right:60%:wrap \ --multi \ --bind='ctrl-a:toggle-all' \ diff --git a/home/dot_config/fish/functions/explain.fish b/home/dot_config/fish/functions/explain.fish new file mode 100644 index 0000000..46680e2 --- /dev/null +++ b/home/dot_config/fish/functions/explain.fish @@ -0,0 +1,28 @@ +function explain --description "Explain a command using GitHub Copilot" + argparse --name=explain \ + 'd/debug' \ + 'h/help' \ + 'hostname=' \ + -- $argv + or return 1 + + if set -q _flag_help + echo "Wrapper around \`copilot\` to explain a command." + echo + echo "USAGE" + echo " explain [flags] " + echo + echo "FLAGS" + echo " -d, --debug Enable debugging" + echo " -h, --help Display help usage" + echo " --hostname HOST GitHub host for authentication" + echo + echo "EXAMPLES" + echo " explain 'du -sh | sort -h'" + echo " explain 'git log --oneline --graph --decorate --all'" + echo " explain 'bfg --strip-blobs-bigger-than 50M'" + return 0 + end + + copilot -p "explain: $argv" --allow-all-tools +end diff --git a/home/dot_config/fish/functions/ghce.fish b/home/dot_config/fish/functions/ghce.fish new file mode 100644 index 0000000..89d7afb --- /dev/null +++ b/home/dot_config/fish/functions/ghce.fish @@ -0,0 +1,3 @@ +function ghce --wraps explain --description "Alias for explain (GitHub Copilot)" + explain $argv +end diff --git a/home/dot_config/fish/functions/ghcs.fish b/home/dot_config/fish/functions/ghcs.fish new file mode 100644 index 0000000..24df3fd --- /dev/null +++ b/home/dot_config/fish/functions/ghcs.fish @@ -0,0 +1,3 @@ +function ghcs --wraps suggest --description "Alias for suggest (GitHub Copilot)" + suggest $argv +end diff --git a/home/dot_config/fish/functions/suggest.fish b/home/dot_config/fish/functions/suggest.fish new file mode 100644 index 0000000..5cc9a05 --- /dev/null +++ b/home/dot_config/fish/functions/suggest.fish @@ -0,0 +1,32 @@ +function suggest --description "Suggest a command using GitHub Copilot" + argparse --name=suggest \ + 'd/debug' \ + 'h/help' \ + 'hostname=' \ + 't/target=' \ + -- $argv + or return 1 + + if set -q _flag_help + echo "Wrapper around \`copilot\` to suggest a command." + echo "Places suggested command on the command line for review/editing." + echo + echo "USAGE" + echo " suggest [flags] " + echo + echo "FLAGS" + echo " -d, --debug Enable debugging" + echo " -h, --help Display help usage" + echo " --hostname HOST GitHub host for authentication" + echo " -t, --target TARGET Target: shell (default), gh, git" + echo + echo "EXAMPLES" + echo " suggest" + echo " suggest -t git 'Undo the most recent local commits'" + echo " suggest -t gh 'Create pull request'" + echo " suggest 'Convert MOV to animated PNG'" + return 0 + end + + copilot -p "suggest: $argv" --allow-all-tools +end diff --git a/home/executable_dot_bash_aliases.tmpl b/home/executable_dot_bash_aliases.tmpl index 865e446..6c2afd2 100644 --- a/home/executable_dot_bash_aliases.tmpl +++ b/home/executable_dot_bash_aliases.tmpl @@ -44,8 +44,8 @@ alias copes='claude --model sonnet' alias copeh='claude --model haiku' alias hcope='claude --model haiku' alias gpt='chatgpt' -alias copilot='gh copilot' -alias suggest='gh copilot suggest -t shell' +alias copilot='copilot' +alias suggest='copilot -p "suggest:" --allow-all-tools' alias spt='spotify_player' alias gitalias='alias | grep "git "' alias mousefix='sudo udevadm trigger' # helped with mouse issues on laptop