2020-01-01 07:45:27 +01:00
|
|
|
# which
|
|
|
|
|
|
|
|
Finds a program file.
|
|
|
|
|
|
|
|
Usage:
|
2020-01-01 08:47:25 +01:00
|
|
|
> which <application> {flags}
|
2020-01-01 07:45:27 +01:00
|
|
|
|
|
|
|
## Parameters
|
|
|
|
|
2020-01-01 08:47:25 +01:00
|
|
|
- application: the name of the command to find the path to
|
|
|
|
|
|
|
|
## Flags
|
|
|
|
|
2020-01-01 07:45:27 +01:00
|
|
|
- --all: list all executables
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
`which` finds the location of an executable:
|
|
|
|
|
|
|
|
```shell
|
2020-06-23 20:21:47 +02:00
|
|
|
> which python
|
|
|
|
─────────┬─────────────────
|
|
|
|
arg │ python
|
|
|
|
path │ /usr/bin/python
|
2021-02-11 09:50:33 +01:00
|
|
|
builtin │ false
|
2020-06-23 20:21:47 +02:00
|
|
|
─────────┴─────────────────
|
|
|
|
```
|
|
|
|
|
|
|
|
```shell
|
|
|
|
> which cargo
|
|
|
|
─────────┬────────────────────────────
|
|
|
|
arg │ cargo
|
|
|
|
path │ /home/bob/.cargo/bin/cargo
|
2021-02-11 09:50:33 +01:00
|
|
|
builtin │ false
|
2020-06-23 20:21:47 +02:00
|
|
|
─────────┴────────────────────────────
|
2020-01-01 07:45:27 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
`which` will identify nushell commands:
|
|
|
|
|
|
|
|
```shell
|
2020-06-23 20:21:47 +02:00
|
|
|
> which ls
|
|
|
|
─────────┬──────────────────────────
|
|
|
|
arg │ ls
|
|
|
|
path │ nushell built-in command
|
2021-02-11 09:50:33 +01:00
|
|
|
builtin │ true
|
2020-06-23 20:21:47 +02:00
|
|
|
─────────┴──────────────────────────
|
|
|
|
```
|
|
|
|
|
|
|
|
```shell
|
|
|
|
> which which
|
|
|
|
─────────┬──────────────────────────
|
|
|
|
arg │ which
|
|
|
|
path │ nushell built-in command
|
2021-02-11 09:50:33 +01:00
|
|
|
builtin │ true
|
2020-06-23 20:21:47 +02:00
|
|
|
─────────┴──────────────────────────
|
2020-01-01 07:45:27 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
Passing the `all` flag identifies all instances of a command or binary
|
|
|
|
|
|
|
|
```shell
|
2020-06-23 20:21:47 +02:00
|
|
|
> which ls --all
|
|
|
|
───┬─────┬──────────────────────────┬─────────
|
2020-01-01 07:45:27 +01:00
|
|
|
# │ arg │ path │ builtin
|
|
|
|
───┼─────┼──────────────────────────┼─────────
|
2021-02-11 09:50:33 +01:00
|
|
|
0 │ ls │ nushell built-in command │ true
|
|
|
|
1 │ ls │ /bin/ls │ false
|
2020-06-23 20:21:47 +02:00
|
|
|
───┴─────┴──────────────────────────┴─────────
|
2020-01-01 07:45:27 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
`which` will also identify local binaries
|
|
|
|
|
|
|
|
```shell
|
2020-06-23 20:21:47 +02:00
|
|
|
> touch foo
|
|
|
|
> chmod +x foo
|
|
|
|
> which ./foo
|
|
|
|
─────────┬────────────────────────────────
|
|
|
|
arg │ ./foo
|
|
|
|
path │ /Users/josephlyons/Desktop/foo
|
2021-02-11 09:50:33 +01:00
|
|
|
builtin │ false
|
2020-06-23 20:21:47 +02:00
|
|
|
─────────┴────────────────────────────────
|
2020-01-01 07:45:27 +01:00
|
|
|
```
|
2021-01-01 18:40:44 +01:00
|
|
|
|
|
|
|
`which` also identifies aliases
|
|
|
|
|
|
|
|
```shell
|
|
|
|
> alias e = echo
|
|
|
|
> which e
|
|
|
|
───┬─────┬───────────────┬─────────
|
|
|
|
# │ arg │ path │ builtin
|
|
|
|
───┼─────┼───────────────┼─────────
|
2021-02-11 09:50:33 +01:00
|
|
|
0 │ e │ Nushell alias │ false
|
2021-01-01 18:40:44 +01:00
|
|
|
───┴─────┴───────────────┴─────────
|
|
|
|
```
|
|
|
|
|
|
|
|
and custom commands
|
|
|
|
|
|
|
|
```shell
|
|
|
|
> def my_cool_echo [arg] { echo $arg }
|
|
|
|
> which my_cool_echo
|
|
|
|
───┬──────────────┬────────────────────────┬─────────
|
|
|
|
# │ arg │ path │ builtin
|
|
|
|
───┼──────────────┼────────────────────────┼─────────
|
2021-02-11 09:50:33 +01:00
|
|
|
0 │ my_cool_echo │ Nushell custom command │ false
|
2021-01-01 18:40:44 +01:00
|
|
|
───┴──────────────┴────────────────────────┴─────────
|
|
|
|
```
|