Skip to content

Instantly share code, notes, and snippets.

@fourthdimension
Created May 1, 2024 01:33
Show Gist options
  • Select an option

  • Save fourthdimension/b9c0b80c60d57406f602fde12fa6470a to your computer and use it in GitHub Desktop.

Select an option

Save fourthdimension/b9c0b80c60d57406f602fde12fa6470a to your computer and use it in GitHub Desktop.
Fish Shell - Wrapper around `gh copilot suggest` to suggest a command based on a natural language description of the desired output effort.
function ghcs --description 'Wrapper around `gh copilot suggest` to suggest a command based on a natural language description of the desired output effort. Supports executing suggested commands if applicable.'
# Check if any arguments were provided
if not set -q argv[1]
echo "Please provide a description of the desired output."
return 1
end
# Combine all arguments into a single query string
set -l query (string join " " $argv)
# Call gh copilot suggest with the provided query
gh copilot suggest -t shell "$query"
end
@fourthdimension
Copy link
Copy Markdown
Author

If you're using fish shell, after defining the function above, you can create an abbreviation that triggers this function when you type '!!'. alias !!='ghcs'

With the abbreviation set, whenever you type '!!' followed by a space in your terminal, it will be expanded to ghcs, waiting for your natural language description. For example:
!! find files modified in the last 24 hours

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment