Skip to main content
added 9 characters in body
Source Link
Gilles 'SO- stop being evil'
  • 865.3k
  • 205
  • 1.8k
  • 2.3k

The instructions in the book are for bash. Zsh is a different program with different key bindings.

In zsh, you can see a list of all commands (external, builtin, function, alias even keywords...) with:

type -m '*'

For just their names:

whence -wm '*' | sed 's/:[^:]*$//'

Or for the names of external commands only:

print -rlo -- $commands:t | less

$commands is an array that contains all external commands. The history modifier :t truncates the directory part of the command paths (keeps only the tail). print -rlo to print them raw in alphabetical order, one per line.

Longer, but less cryptic:

for p in "$path[@]"; do (cd ${p:-.} && ls); done | sort -u | less

This can be adjusted to work in any sh-style shell:

(IFS=:; for p in $PATH; do (cd ${p:-.} && ls); done) | sort -u | less

(All the commands I list here assume that there are no “unusual” characters in command paths.)

The instructions in the book are for bash. Zsh is a different program with different key bindings.

In zsh, you can see a list of all commands (external, builtin, function, alias even keywords...) with:

type -m '*'

For just their names:

whence -wm '*' | sed 's/:[^:]*$//'

Or for the names of external commands only:

print -rlo -- $commands:t | less

$commands is an array that contains all external commands. The history modifier :t truncates the directory part of the command paths (keeps only the tail). print -rlo to print them raw in alphabetical order, one per line.

Longer, but less cryptic:

for p in "$path[@]"; do (cd ${p:-.} && ls); done | sort -u | less

This can be adjusted to work in any shell:

(IFS=:; for p in $PATH; do (cd ${p:-.} && ls); done) | sort -u | less

(All the commands I list here assume that there are no “unusual” characters in command paths.)

The instructions in the book are for bash. Zsh is a different program with different key bindings.

In zsh, you can see a list of all commands (external, builtin, function, alias even keywords...) with:

type -m '*'

For just their names:

whence -wm '*' | sed 's/:[^:]*$//'

Or for the names of external commands only:

print -rlo -- $commands:t | less

$commands is an array that contains all external commands. The history modifier :t truncates the directory part of the command paths (keeps only the tail). print -rlo to print them raw in alphabetical order, one per line.

Longer, but less cryptic:

for p in "$path[@]"; do (cd ${p:-.} && ls); done | sort -u | less

This can be adjusted to work in any sh-style shell:

(IFS=:; for p in $PATH; do (cd ${p:-.} && ls); done) | sort -u | less

(All the commands I list here assume that there are no “unusual” characters in command paths.)

simplifications and improvements.
Source Link
Stéphane Chazelas
  • 584.8k
  • 96
  • 1.1k
  • 1.7k

The instructions in the book are for bash. Zsh is a different program with different key bindings.

In zsh, you can see a list of all commands (external commands, not builtinsbuiltin, function, alias even keywords...) with:

type -m '*'

For just their names:

whence -wm '*' | sed 's/:[^:]*$//'

Or for the names of external commands only:

print -lrlo ${(o)-- $commands:t} | less

$commands is an array that contains all external commands. The parameter expansion flag o sorts the list. The history modifier :t truncates the directory part of the command paths (keeps only the tail). print -rlo to print them raw in alphabetical order, one per line.

Longer, but less cryptic:

for p in $path;"$path[@]"; do (cd $p${p:-.} && ls); done | sort -u | less

This can be adjusted to work in any shell:

(IFS=:; for p in $PATH; do (cd $p${p:-.} && ls); done) | sort -u | less

(All the commands I list here assume that there are no “unusual” characters in command paths.)

The instructions in the book are for bash. Zsh is a different program with different key bindings.

In zsh, you can see a list of all commands (external commands, not builtins) with

print -l ${(o)$commands:t} | less

$commands is an array that contains all external commands. The parameter expansion flag o sorts the list. The history modifier :t truncates the directory part of the command paths.

Longer, but less cryptic:

for p in $path; do (cd $p && ls); done | sort | less

This can be adjusted to work in any shell:

(IFS=:; for p in $PATH; do (cd $p && ls); done) | sort | less

(All the commands I list here assume that there are no “unusual” characters in command paths.)

The instructions in the book are for bash. Zsh is a different program with different key bindings.

In zsh, you can see a list of all commands (external, builtin, function, alias even keywords...) with:

type -m '*'

For just their names:

whence -wm '*' | sed 's/:[^:]*$//'

Or for the names of external commands only:

print -rlo -- $commands:t | less

$commands is an array that contains all external commands. The history modifier :t truncates the directory part of the command paths (keeps only the tail). print -rlo to print them raw in alphabetical order, one per line.

Longer, but less cryptic:

for p in "$path[@]"; do (cd ${p:-.} && ls); done | sort -u | less

This can be adjusted to work in any shell:

(IFS=:; for p in $PATH; do (cd ${p:-.} && ls); done) | sort -u | less

(All the commands I list here assume that there are no “unusual” characters in command paths.)

Source Link
Gilles 'SO- stop being evil'
  • 865.3k
  • 205
  • 1.8k
  • 2.3k

The instructions in the book are for bash. Zsh is a different program with different key bindings.

In zsh, you can see a list of all commands (external commands, not builtins) with

print -l ${(o)$commands:t} | less

$commands is an array that contains all external commands. The parameter expansion flag o sorts the list. The history modifier :t truncates the directory part of the command paths.

Longer, but less cryptic:

for p in $path; do (cd $p && ls); done | sort | less

This can be adjusted to work in any shell:

(IFS=:; for p in $PATH; do (cd $p && ls); done) | sort | less

(All the commands I list here assume that there are no “unusual” characters in command paths.)