Difference between revisions of "Bash Shell"
| Line 38: | Line 38: | ||
Double Square Brackets [[ ... ]] is the syntax for conditional expressions (similar to ''test'' but more powerful)</br> | Double Square Brackets [[ ... ]] is the syntax for conditional expressions (similar to ''test'' but more powerful)</br> | ||
Change to the directory of the script | === Change to the directory of the script === | ||
<code>cd "$(dirname "$(readlink -f "$0")")"</code></br> | <code>cd "$(dirname "$(readlink -f "$0")")"</code></br> | ||
1. ''readlink -f "$0"'' determines the path of the current script ($0)</br> | 1. ''readlink -f "$0"'' determines the path of the current script ($0)</br> | ||
2. ''dirname'' converts the path of the script to its directory</br> | 2. ''dirname'' converts the path of the script to its directory</br> | ||
3. ''cd'' changes the working directory to the directory it receives from ''dirname''</br> | 3. ''cd'' changes the working directory to the directory it receives from ''dirname''</br> | ||
Revision as of 14:25, 24 March 2023
Hotkeys
CTRL + a move to beginning
CTRL + e move to end
ALT + f move forward by one word
ALT + b move backward by one word
CTRL + n down arrow
CTRL + p up arrow
Text Control
CTRL + k cut after cursor
CTRL + l clear
CTRL + u cut before cursor
CTRL + w cut word before cursor
CTRL + y paste
CTRL + _ undo typing
ALT + r undo changes made to command from history
Misc
CTRL + r backward search
CTRL + g leave search without running a command
CTRL + j copy current matched command to cli without running it
CTRL + s stop output
CTRL + q resume output
CTRL + d escape current shell or delete character under cursor
CTRL + t switch character before cursor with cursor
Functions
Single Parenthesis ( ... ) is creating a subshell for nested commands
Double Parenthesis (( ... )) is for arithmetic operation
Single Square Bracket [ ... ] is the syntax for the POSIX test
Double Square Brackets ... is the syntax for conditional expressions (similar to test but more powerful)
Change to the directory of the script
cd "$(dirname "$(readlink -f "$0")")"
1. readlink -f "$0" determines the path of the current script ($0)
2. dirname converts the path of the script to its directory
3. cd changes the working directory to the directory it receives from dirname