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
|
|
|
|
builtin │ No
|
|
|
|
─────────┴─────────────────
|
|
|
|
```
|
|
|
|
|
|
|
|
```shell
|
|
|
|
> which cargo
|
|
|
|
─────────┬────────────────────────────
|
|
|
|
arg │ cargo
|
|
|
|
path │ /home/bob/.cargo/bin/cargo
|
|
|
|
builtin │ No
|
|
|
|
─────────┴────────────────────────────
|
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
|
|
|
|
builtin │ Yes
|
|
|
|
─────────┴──────────────────────────
|
|
|
|
```
|
|
|
|
|
|
|
|
```shell
|
|
|
|
> which which
|
|
|
|
─────────┬──────────────────────────
|
|
|
|
arg │ which
|
|
|
|
path │ nushell built-in command
|
|
|
|
builtin │ Yes
|
|
|
|
─────────┴──────────────────────────
|
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
|
|
|
|
───┼─────┼──────────────────────────┼─────────
|
|
|
|
0 │ ls │ nushell built-in command │ Yes
|
2020-06-23 20:21:47 +02:00
|
|
|
1 │ ls │ /bin/ls │ No
|
|
|
|
───┴─────┴──────────────────────────┴─────────
|
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
|
|
|
|
builtin │ No
|
|
|
|
─────────┴────────────────────────────────
|
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
|
|
|
|
───┼─────┼───────────────┼─────────
|
|
|
|
0 │ e │ Nushell alias │ No
|
|
|
|
───┴─────┴───────────────┴─────────
|
|
|
|
```
|
|
|
|
|
|
|
|
and custom commands
|
|
|
|
|
|
|
|
```shell
|
|
|
|
> def my_cool_echo [arg] { echo $arg }
|
|
|
|
> which my_cool_echo
|
|
|
|
───┬──────────────┬────────────────────────┬─────────
|
|
|
|
# │ arg │ path │ builtin
|
|
|
|
───┼──────────────┼────────────────────────┼─────────
|
|
|
|
0 │ my_cool_echo │ Nushell custom command │ No
|
|
|
|
───┴──────────────┴────────────────────────┴─────────
|
|
|
|
```
|