2022-10-17 17:46:38 +00:00
---
stage: Create
group: Code Review
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/product/ux/technical-writing/#assignments
---
2020-10-26 12:55:03 +00:00
2022-10-19 14:32:40 +00:00
<!--
2022-10-17 17:46:38 +00:00
This documentation is auto generated by a script.
2023-02-07 08:22:45 +00:00
Please do not edit this file directly. Run `make gen-docs` instead.
2022-10-19 14:32:40 +00:00
-->
2020-08-21 17:30:40 +00:00
2022-10-21 14:38:48 +00:00
# `glab alias set`
2020-08-21 17:30:40 +00:00
2022-10-17 17:46:38 +00:00
Set an alias.
2020-10-26 12:55:03 +00:00
2022-10-17 17:46:38 +00:00
## Synopsis
2020-08-21 17:30:40 +00:00
2020-09-11 11:43:32 +00:00
Declare a word as a command alias that will expand to the specified command(s).
The expansion may specify additional arguments and flags. If the expansion
includes positional placeholders such as '$1', '$2', etc., any extra arguments
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). This allows you
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
2022-10-21 14:38:48 +00:00
you have installed Git on Windows in some other way, shell aliases may not work for you.
2020-09-11 11:43:32 +00:00
Quotes must always be used when defining a command as in the examples.
2022-10-17 17:46:38 +00:00
```plaintext
glab alias set < alias name > '< command > ' [flags]
```
2020-08-21 17:30:40 +00:00
2022-10-17 17:46:38 +00:00
## Examples
2020-08-21 17:30:40 +00:00
2022-10-17 17:46:38 +00:00
```plaintext
$ glab alias set mrv 'mr view'
$ glab mrv -w 123
2023-12-06 09:11:57 +00:00
# glab mr view -w 123
2020-09-11 11:43:32 +00:00
2022-10-17 17:46:38 +00:00
$ glab alias set createissue 'glab create issue --title "$1"'
$ glab createissue "My Issue" --description "Something is broken."
# => glab create issue --title "My Issue" --description "Something is broken."
2020-08-21 17:30:40 +00:00
2022-10-17 17:46:38 +00:00
$ glab alias set --shell igrep 'glab issue list --assignee="$1" | grep $2'
$ glab igrep user foo
2023-12-06 09:11:57 +00:00
# glab issue list --assignee="user" | grep "foo"
2020-09-11 11:43:32 +00:00
2022-10-17 17:46:38 +00:00
```
2020-08-21 17:30:40 +00:00
2022-10-21 14:38:48 +00:00
## Options
2020-08-21 17:30:40 +00:00
2022-10-17 17:46:38 +00:00
```plaintext
2020-09-11 11:43:32 +00:00
-s, --shell Declare an alias to be passed through a shell interpreter
2022-10-17 17:46:38 +00:00
```
2020-08-21 17:30:40 +00:00
2022-10-21 14:38:48 +00:00
## Options inherited from parent commands
2020-09-29 05:56:15 +00:00
2022-10-17 17:46:38 +00:00
```plaintext
2020-10-26 12:55:03 +00:00
--help Show help for command
2022-10-17 17:46:38 +00:00
```