Shells
BASH: Bourn Again SHell
${var::-3} also doesnt work on ZSH. Use ${var:0:-3} instead
|
chop on variable
echo ${a#gg} (2)
echo ${a%.*} (3)
echo ${var:3} (4)
echo ${var::-2} (5)
1 | ${…} expand everything inside |
2 | # chop gg from the beginning of variable a |
3 | % chop gg from the end of variable a |
4 | : chop 3 chars from the beginning of variable a |
5 | :: chop from the end. |
6 | Can use regex inside {} like .* , ??? |
${var::-2} only works with bash v4+ . Use ${var::${#var}-2} for older bash
|
ZSH
- How to unset things in zsh?
-
unset unhash unalias unlimit unsetopt unfunction z unset -f z #bash compliant
- How to write Completions?
-
https://github.com/zsh-users/zsh-completions/blob/master/zsh-completions-howto.org
Shell Scripting
${…} tells the shell to expand whatever is inside it
|
- How to keymap a script to zle?
-
https://unix.stackexchange.com/questions/79897/how-can-i-use-bindkey-to-run-a-script
- How to make a keybinging with ZSH?
-
https://stackoverflow.com/questions/18042685/list-of-zsh-bindkey-commands https://jdhao.github.io/2019/06/13/zsh_bind_keys/
- Interactive cli scripts?
- Bash scripting frameworks?
- Awesome shell?
- What is the difference between
…
and$(…)
? -
Command Substitution
-
older vs newer syntax
-
man bash
-
- Parameter Expansion
-
bash days=(sun mon tue wed thu fri sat) echo ${days[3]} echo ${days[-2]} echo ${days[+3]} echo ${days[@]}