Skip to content

Instantly share code, notes, and snippets.

@vhbui02
Last active May 3, 2023 07:38
Show Gist options
  • Save vhbui02/ad4961b8968b4cba0e963a1a18e77706 to your computer and use it in GitHub Desktop.
Save vhbui02/ad4961b8968b4cba0e963a1a18e77706 to your computer and use it in GitHub Desktop.
[type command] locate a command and describe its type #fish

type [OPTIONS] NAME

Option

-a or --all: prints exe, function (with definition expansion), and built-in.

-s or --short: suppresses function definition expansion.

-f or --no-function: suppresses function and built-in lookup.

-t or --type: prints the type currently working of command:

  • function
  • builtin
  • file

If NAME is a shell function, a builtin, or a disk file, respectively

-p or --path: prints the path to the currently working command with its coresponding type

  • The path to NAME if NAME is resolves to an executable file in PATH. E.g. /c/Python311/python
  • The path to the script containing the definition of function NAME if NAME resolves to a function loaded from a disk file. E.g. /c/Users/hacki/.dotfiles/fish/functions/python.fish
  • Nothing otherwise.

-P or --force-path: returns ONLY:

  • The path to the exe file (presumes that the exe is found inside PATH)
  • Nothing otherwise.

It omitted function and builtin even though they still exists.

-q or --query: suppresses all output, VERY USEFUL when checking the exit status of a command to determine whether it's a command or not?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment