GitHunt

How to denote required and optional arguments on the command line

  • <required_argument>
  • [optional_argument]

Option-arguments are shown separated from their options by characters, except when the option-argument is enclosed in the '[' and ']' notation to indicate that it is optional.

https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/V1_chap12.html

Note

Zsh does not expand the tilde (~) in single or double quotes.

initial tildes and equals signs are not expanded

http://zsh.sourceforge.net/Guide/zshguide05.html

Best practices

  • Using a parenthesized command aka subshell
    • e.g. (cd <directory> && ls)
  • Using cd <directory> and cd -
  • Using pushd <directory> and popd

Decision tree

  1. If your command can be written as a one-liner, use a subshell..
  2. If you switch to several different directories in a row, use pushd <directory> and popd.
  3. Otherwise, use cd <directory> and cd -.

Languages

Batchfile55.2%PowerShell36.3%JavaScript5.1%VBA3.4%

Contributors

Created December 31, 2017
Updated March 20, 2026
tatsuyafujisaki/script-cheat-sheet | GitHunt