Skip to content

Latest commit

 

History

History
129 lines (102 loc) · 3.93 KB

File metadata and controls

129 lines (102 loc) · 3.93 KB

BASH (Oh My) ZSH

shortcuts

keys action

ESCESC

inserts the last command with sudo prefix (requires sudo plugin).

ESC+.

inserts the last argument of the previous history line, repeat to go back in history. (Same in Bash.)

ESC+'

quotes the whole line. (Useful for su -c or ssh).

ESC+q

clears the line and inserts it again on the next prompt, allowing you to issue an interim command.

ESC+RETURN

inserts a literal newline, so you can edit longer commands easily.

<(command)

returns the filename (in /dev/fd if supported or as a FIFO) of the pipe given by command for reading. (For example, use diff <(ruby foo.rb) <(ruby-1.9 foo.rb) to compare two program outputs).

cd old new

substitutes old with new once in the pwd and chdirs there.

!$

expands to the previous history line’s last argument, !^ expands to the first argument, !:n to the n-th argument.

=foo

expands to the full path of foo in the PATH (like which foo).

for src (*.c) { …​ }

abbreviates for src in *.c do …​ done (which is actually memorizable). You can even drop the curly braces if you don’t have ; in the command.

<42-69>

globs numbers between 42 and 69. Drop the number(s) to make it open-valued. {42..69} expands to the numbers between 42 and 69.

***

expands recursively like **, but follows symbolic links.

source: leahneukirchen

automatic install and configure

bash
$> sh -c "$(curl -fsSL https://raw.githubusercontent.com/jujumo/memento/refs/heads/main/coding/linux/zsh-setup.sh)"

manual install

bash
$> sudo apt-get install zsh curl git
$> sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
$> sh -c "$(curl -fsSL https://raw.githubusercontent.com/jujumo/memento/refs/heads/main/coding/linux/zsh-setup.sh)"
Note
if you get an error mentioning missing remote-https, please refer to git section in link:../../misc/synology.adoc .

configure

get my theme

bash
$> wget https://raw.githubusercontent.com/jujumo/memento/main/coding/linux/jumo.zsh-theme -O ~/.oh-my-zsh/themes/jumo.zsh-theme
$> curl https://raw.githubusercontent.com/jujumo/memento/main/coding/linux/jumo.zsh-theme -o ~/.oh-my-zsh/themes/jumo.zsh-theme  # or use curl if you prefer

enable plugins

bash
$> cat <<EOT >> profile.patch
11c11
< ZSH_THEME="robbyrussell"
---
> ZSH_THEME="jumo"
73c73,82
< plugins=(git)
---
> plugins=(
>         cp
>         gitfast
>         common-aliases
>         rsync
>         debian
>         sudo
>         screen
>         docker
> )
EOT
$> patch .zshrc -i profile.patch
$> . ~/.zshrc  # apply changes

configure HOME and END keys.

In some cases, through ssh, HOME and END does not work as expected. Adding the following to .zshrc usually restore the their behavior.

.zshrc
...
bindkey "\033[1~" beginning-of-line
bindkey "\033[4~" end-of-line

   or

bindkey  "^[[F"   end-of-line
bindkey  "^[[3~"  delete-char

.*rc files

complete list of which zsh config files are loaded

Interactive login Interactive non═login Script

/etc/zshenv

A

A

A

~/.zshenv

B

B

B

/etc/zprofile

C

 — 

 — 

~/.zprofile

D

 — 

 — 

/etc/zshrc

E

C

 — 

~/.zshrc

F

D

 — 

/etc/zlogin

G

 — 

 — 

~/.zlogin

H

 — 

 — 

on logout

~/.zlogout

I

 — 

 — 

/etc/zlogout

J

 — 

 —