Created
May 1, 2024 01:33
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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