print

Send to Kindle
home » snippets » zsh » print


Notes

# put the arguments onto the editing buffer stack
print -z

# Prompt escapes / using colors
print -P '%Bbold%Sreverse%b%s'

# don't interpret special character sequences like `\n` 
print -r -- '\n'

Flags

-P
Use % as in prompts
-n
Don't put a newline at the end in case there's more output to follow
-c
Print the output in columns --- this means that print -c * has the effect of a sort of poor person's ls, only faster
-l
_ use one line per argument instead of one column, which is sometimes useful for sticking lists into files, and for working out what part of an array parameter is in each ele_ment.
-s
Place the results in the history list instead of on the standard output. Each argument to the print command is treated as a single word in the history, regardless of its content.
-S
Place the results in the history list instead of on the standard output. In this case only a single argument is allowed; it will be split into words as if it were a full shell command line. The effect is similar to reading the line from a history file with the HIST_LEX_WORDS option active.
-u n
Print the arguments to file descriptor n.  (e.g. print -u 2 hello  ≈  print hello 2>/dev/null

Sorting Options

-o
Print the arguments sorted in ascending order.
-O
Print the arguments sorted in descending order.
-i
If given together with -o or -O, sorting is performed case-independently.