Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Quick Reference

A consolidated reference for hash shell features.

Command Line Options

OptionDescription
-c stringExecute commands from string
-iForce interactive mode
-l, --loginRun as login shell
-sRead from stdin
-v, --versionPrint version
-h, --helpShow help

Key Bindings

KeyAction
Left/RightMove cursor
Up/DownHistory navigation
Ctrl+ABeginning of line
Ctrl+EEnd of line
Home/EndBeginning/End of line

Editing

KeyAction
BackspaceDelete before cursor
DeleteDelete at cursor
Ctrl+UDelete to beginning
Ctrl+KDelete to end
Ctrl+WDelete word

Other

KeyAction
TabAuto-complete
Ctrl+LClear screen
Ctrl+CCancel line
Ctrl+DEOF / Exit

Operators

OperatorDescription
|Pipe stdout to stdin
>Output to file (overwrite)
>>Output to file (append)
<Input from file
2>Stderr to file
&>Both stdout and stderr
2>&1Stderr to stdout
&&Run if previous succeeded
||Run if previous failed
;Run sequentially
&Run in background

Special Variables

VariableDescription
$?Exit code of last command
$$Shell process ID
$0Shell/script name
$1-$9Positional arguments
$#Number of arguments
$@All arguments (separate)
$*All arguments (single)

Test Operators

File Tests

TestDescription
-eExists
-fRegular file
-dDirectory
-rReadable
-wWritable
-xExecutable
-sSize > 0
-LSymbolic link

String Tests

TestDescription
-zEmpty string
-nNon-empty string
=Equal
!=Not equal

Numeric Tests

TestDescription
-eqEqual
-neNot equal
-ltLess than
-leLess or equal
-gtGreater than
-geGreater or equal

PS1 Escape Sequences

SequenceDescription
\wFull path
\WCurrent directory
\uUsername
\hHostname
\gGit branch + status
\eExit code color
\$$ or #
\nNewline

History Expansion

PatternDescription
!!Last command
!nCommand number n
!-nn commands ago
!prefixLast starting with prefix

Environment Variables

VariableDescription
HISTSIZECommands in memory
HISTFILESIZECommands in file
HISTFILEHistory file location
HISTCONTROLHistory behavior
PS1Prompt format
PATHCommand search path
HOMEHome directory
EDITORDefault editor

Built-in Commands

CommandDescription
aliasDefine/list aliases
unaliasRemove alias
cdChange directory
pwdPrint working directory
echoPrint arguments
exportSet environment variable
sourceExecute file in current shell
exitExit shell
logoutExit login shell
historyShow command history
jobsList background jobs
fgBring job to foreground
bgContinue job in background
killSend signal to process
testEvaluate expression
[Same as test
trueReturn success
falseReturn failure

Configuration Files

FileWhen Loaded
/etc/profileLogin shell
~/.hash_profileLogin shell
~/.profileLogin shell (fallback)
~/.hashrcInteractive shell
~/.hash_logoutLogin shell exit