github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/docs/commands/which.md (about)

     1  # `which`
     2  
     3  > Locate command origin
     4  
     5  ## Description
     6  
     7  `which` locates a command's origin. If STDOUT is a TTY, then it's output will be
     8  human readable. If STDOUT is a pipe then it's output will be a simple list.
     9  
    10  `which` can take multiple parameters, each representing a different command you
    11  want looked up.
    12  
    13  ## Usage
    14  
    15  ```
    16  which command... -> <stdout>
    17  ```
    18  
    19  ## Examples
    20  
    21  **TTY output:**
    22  
    23  ```
    24  » which cat dog jobs git dug
    25  cat => (/bin/cat) cat - concatenate and print files
    26  dog => unknown
    27  jobs => (alias) fid-list --jobs => (builtin) Lists all running functions within the current Murex session
    28  git => (/opt/homebrew/bin/git -> ../Cellar/git/2.41.0/bin/git) git - the stupid content tracker
    29  dug => (murex function) A bit like dig but which outputs JSON
    30  ```
    31  
    32  **Piped output:**
    33  
    34  ```
    35  » which cat dog jobs git dug -> cat
    36  /bin/cat
    37  unknown
    38  alias
    39  /opt/homebrew/bin/git
    40  function
    41  ```
    42  
    43  ## Detail
    44  
    45  There are a few different types of commands:
    46  
    47  ### alias
    48  
    49  This will be represented in `which` and `type` by the term **alias** and, when
    50  STDOUT is a TTY, `which` will follow the alias to print what command the alias
    51  points to.
    52  
    53  ### function
    54  
    55  This is a Murex function (defined via `function`) and will be represented in
    56  `which` and `type` by the term **function**.
    57  
    58  ### private
    59  
    60  This is a private function (defined via `private`) and will be represented in
    61  `which` and `type` by the term **private**.
    62  
    63  ### builtin
    64  
    65  This is a shell builtin, like `out` and `exit`. It will be represented in
    66  `which` and `type` by the term **builtin**.
    67  
    68  ### external executable
    69  
    70  This is any other external command, such as `systemctl` and `python`. This
    71  will be represented in `which` by the path to the executable. When STDOUT is a
    72  TTY, `which` will also print the destination path of any symlinks too.
    73  
    74  In `type`, it is represented by the term **executable**.
    75  
    76  ## See Also
    77  
    78  * [`alias`](../commands/alias.md):
    79    Create an alias for a command
    80  * [`exec`](../commands/exec.md):
    81    Runs an executable
    82  * [`exit`](../commands/exit.md):
    83    Exit murex
    84  * [`fexec` ](../commands/fexec.md):
    85    Execute a command or function, bypassing the usual order of precedence.
    86  * [`function`](../commands/function.md):
    87    Define a function block
    88  * [`out`](../commands/out.md):
    89    Print a string to the STDOUT with a trailing new line character
    90  * [`type`](../commands/type.md):
    91    Command type (function, builtin, alias, etc)
    92  
    93  <hr/>
    94  
    95  This document was generated from [builtins/core/management/which_doc.yaml](https://github.com/lmorg/murex/blob/master/builtins/core/management/which_doc.yaml).