diff --git a/command/alias.go b/command/alias.go index 5baceff33..87573fad2 100644 --- a/command/alias.go +++ b/command/alias.go @@ -41,10 +41,13 @@ var aliasSetCmd = &cobra.Command{ that follow the invocation of an alias will be inserted appropriately. If '--shell' is specified, the alias will be run through a shell interpreter (sh or pwsh). This allows you - to compose commands with "|" or redirect output. Note that extra arguments following the alias + to compose commands with "|" or redirect with ">". Note that extra arguments following the alias will not be automatically passed to the expanded expression. To have a shell alias receive arguments, you must explicitly accept them using "$1", "$2", etc or "$@" to accept all of them. + Platform note: on Windows, shell aliases are executed via "sh" as installed by Git For Windows. If + you have installed git on Windows in some other way, shell aliases may not work for you. + Quotes must always be used when defining a command as in the examples.`), Example: heredoc.Doc(` $ gh alias set pv 'pr view' @@ -57,15 +60,9 @@ var aliasSetCmd = &cobra.Command{ $ gh epicsBy vilmibm #=> gh issue list --author="vilmibm" --label="epic" - # On macOS and Linux: $ gh alias set --shell igrep 'gh issue list --label="$1" | grep $2' $ gh igrep epic foo - #=> gh issue list --label="epic" | grep "foo" - - # On Windows (Powershell): - $ gh alias set --shell igrep 'gh issue list --label=$args[0] | Select-String -Pattern $args[1] - $ gh igrep epic foo - #=> gh issue list --label=epic | Select-String -Pattern foo`), + #=> gh issue list --label="epic" | grep "foo"`), Args: cobra.ExactArgs(2), RunE: aliasSet, }