Files
Shell-Oneliner/README.md
2023-01-13 12:09:10 +01:00

47 lines
1.2 KiB
Markdown

# Shell-Oneliner
Based on https://github.com/onceupon/Bash-Oneliner
but mainly for ZSH, my personal needs and configuration.
## Terminal Tricks
```
Ctrl + r : begins a backward search through command history.(keep pressing Ctrl + r to move backward)
Ctrl + a : move to the beginning of line.
Ctrl + e : move to the end of line.
Ctrl + w : cut the word before the cursor; then Ctrl + y paste it
Ctrl + u : cut the line; then Ctrl + y paste it
Ctrl + x + Ctrl + e : launch editor defined by $EDITOR to input your command. Useful for multi-line commands.
Esc + c : converts letter under the cursor to uppercase, rest of the word to lowercase.
```
### ... with my own configuration
```
Ctrl + t : print current date
```
### environment variables
```
$0 : name of shell or shell script.
$1, $2, $3, ... : positional parameters.
$# : number of positional parameters.
$? : most recent foreground pipeline exit status.
$- : current options set for the shell.
$$ : pid of the current shell (not subshell).
$! : is the PID of the most recent background command.
$USER : current username
$HOSTNAME : current hostname
```
### length of variable
```
var="some string"
echo ${#var}
# 11
```