zimfw shell

zsh

1
2
3
4
sudo apt install zsh

#zsh替换为你的默认shell
chsh -s $(which zsh)

zimfw

Automatic installation

https://ghproxy.com/https://raw.githubusercontent.com/zimfw/install/master/install.zsh

1
curl -fsSL https://raw.githubusercontent.com/zimfw/install/master/install.zsh | zsh

) Using Zsh version 5.8
) ZIM_HOME not set, using the default one.
密码:
) Changed your default shell to /usr/bin/zsh
! You seem to be already calling compinit in /etc/zsh/zshrc. Please remove it, because Zim’s completion module will call compinit for you.
) Downloaded the Zim script to /home/cs/.zim/zimfw.zsh
) Prepended Zim template to /home/cs/.zimrc
) Prepended Zim template to /home/cs/.zshrc

.

.

.

Manual installation

~/.zshrc

1
2
3
ZIM_HOME=~/.zim

https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh

$ cat /.zshrc | grep zstyle
#zstyle ‘:zim:zmodule’ use ‘degit’
#zstyle ‘:zim:git’ aliases-prefix ‘g’
#zstyle ‘:zim:input’ double-dot-expand yes
#zstyle ‘:zim:termtitle’ format ‘%1

~/.zimrc

~/.zim/modules/

$ cat ~/.zimrc | grep zmodule
zmodule environment
zmodule git
zmodule input
zmodule termtitle
zmodule utility
zmodule duration-info
zmodule git-info
zmodule asciiship
zmodule zsh-users/zsh-completions –fpath src
zmodule completion
zmodule zsh-users/zsh-syntax-highlighting
zmodule zsh-users/zsh-history-substring-search
zmodule zsh-users/zsh-autosuggestions

Uninstalling

1
#rm -rf ~/.zim ~/.zimrc

$ ls -l ~/.z*
-rw——- 1 cs cs 1574 4月 8 18:54 /home/cs/.zimrc
-rw——- 1 cs cs 3587 4月 8 18:54 /home/cs/.zshrc

/home/cs/.zim:
总用量 40
drwxr-xr-x 15 cs cs 4096 4月 8 19:23 modules
-rw-r–r– 1 cs cs 36117 4月 8 18:54 zimfw.zsh

modules

zimrc add zmodule

autojump

https://github.com/wting/autojump

1
sudo apt install autojump

/usr/share/doc/autojump/README.Debian

autojump 将只跳到先前 cd 命令到过的目录

j

1
2
3
4
5
❯ j k8s
/home/cs/oss/k8s-1.26
❯ j w k8s #权限小的目录
/home/cs/data/VM/k8s

stat

选项可以查看访问过的目录权重

1
2
3
4
5
6
7
8
9
10
11
12
13
❯ j --stat
10.0: /home/cs/data/VM/k8s
14.1: /home/cs/oss/k8s-1.26
14.1: /opt/tools
20.0: /home/cs/oss/hexo
________________________________________

58: total weight
4: number of entries
10.00: current directory weight

data: /home/cs/.local/share/autojump/autojump.txt #统计存储日志

fzf

https://github.com/junegunn/fzf#examples

1
2
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install

Downloading bin/fzf …
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 –:–:– –:–:– –:–:– 0
100 1340k 100 1340k 0 0 5941 0 0:03:50 0:03:50 –:–:– 7241

  • Checking fzf executable … 0.39.0
    Do you want to enable fuzzy auto-completion? ([y]/n) y
    Do you want to enable key bindings? ([y]/n) y

Generate /home/cs/.fzf.bash … OK
Generate /home/cs/.fzf.zsh … OK

Do you want to update your shell configuration files? ([y]/n) y

Update /home/cs/.bashrc:

  • [ -f ~/.fzf.bash ] && source ~/.fzf.bash
    • Added

Update /home/cs/.zshrc:

  • [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
    • Added

Finished. Restart your shell or reload config file.
source ~/.bashrc # bash
source ~/.zshrc # zsh

Use uninstall script to remove fzf.

For more information, see: https://github.com/junegunn/fzf

fzf-tab

~/.zimrc

1
2
3
git clone --depth 1 https://github.com/Aloxaf/fzf-tab.git  /.zim/modules/fzf-tab
#fzf-tab ALSO needs fzf installed
zmodule Aloxaf/fzf-tab
1
2
3
4
5
6
7
8
9
10
# disable sort when completing `git checkout`
zstyle ':completion:*:git-checkout:*' sort false
# set descriptions format to enable group support
zstyle ':completion:*:descriptions' format '[%d]'
# set list-colors to enable filename colorizing
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
# preview directory's content with exa when completing cd
zstyle ':fzf-tab:complete:cd:*' fzf-preview 'exa -1 --color=always $realpath'
# switch group using `,` and `.`
zstyle ':fzf-tab:*' switch-group ',' '.'

https://github.com/Aloxaf/fzf-tab/wiki/Configuration

powerlevel10k

doc https://github.com/romkatv/powerlevel10k#installation

1
2
#add ~/.zimrc
zmodule romkatv/powerlevel10k

/home/cs/.zim/modules/powerlevel10k

p10k安装

1
p10k configure

New config: ~/.p10k.zsh.
Backup of ~/.zshrc: /tmp/.zshrc.JO4Ns3iulN.

See ~/.zshrc changes:

diff /tmp/.zshrc.JO4Ns3iulN ~/.zshrc

File feature requests and bug reports at
https://github.com/romkatv/powerlevel10k/issues

font

https://www.nerdfonts.com/font-downloads

https://github.com/ryanoasis/nerd-fonts/releases/tag/v2.3.3

icons

https://www.nerdfonts.com/cheat-sheet

~/.p10k.zsh

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
POWERLEVEL9K_BATTERY_CHARGING='yellow'
POWERLEVEL9K_BATTERY_CHARGED='green'
POWERLEVEL9K_BATTERY_DISCONNECTED='$DEFAULT_COLOR'
POWERLEVEL9K_BATTERY_LOW_THRESHOLD='10'
POWERLEVEL9K_BATTERY_LOW_COLOR='red'
POWERLEVEL9K_BATTERY_ICON='\uf1e6 '
POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX=''
POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX='\uf0da'
#POWERLEVEL9K_VCS_GIT_ICON='\ue60a'

POWERLEVEL9K_VCS_MODIFIED_BACKGROUND='yellow'
POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND='yellow'
#POWERLEVEL9K_VCS_UNTRACKED_ICON='?'

POWERLEVEL9K_SHORTEN_STRATEGY="truncate_middle"
POWERLEVEL9K_SHORTEN_DIR_LENGTH=4

#POWERLEVEL9K_CUSTOM_TIME_FORMAT="%D{\uf017 %H:%M:%S}"
POWERLEVEL9K_TIME_FORMAT="%D{\uf017 %H:%M \uf073 %d.%m.%y}"

POWERLEVEL9K_STATUS_VERBOSE=false

POWERLEVEL9K_PROMPT_ON_NEWLINE=true

exa

代替ls

https://github.com/ogham/exa/releases/tag/v0.10.1

1
❯ exa -lh -T --icons ./
  • -T, –tree: 递归到树视图中的子目录
  • –icons: 显示图标
1
❯ exa -lh -T  --icons ./   -L 1
  • -L, –level=(depth): 限制递归的深度
  • -D, –only-dirs: 只列出目录
1
2
3
4
5
6
7
8
debian# ln -s /home/cs/.zshrc /root/.zshrc
debian# ln -s /home/cs/.zimrc /root/.zimrc

debian# ln -s /home/cs/.fzf.zsh /root/.fzf.zsh
debian# ln -s /home/cs/.p10k.zsh /root/.p10k.zsh
debian#
debian# ln -s /home/cs/.zim/modules /root/.zim/modules

lrwxrwxrwx 1 root root 15 4月 15 20:05 /root/.zimrc -> /home/cs/.zimrc
lrwxrwxrwx 1 root root 15 4月 15 20:05 /root/.zshrc -> /home/cs/.zshrc

lrwxrwxrwx 1 root root 18 4月 15 20:07 /root/.p10k.zsh -> /home/cs/.p10k.zsh

thefuck

https://github.com/nvbn/thefuck

1
pip3 install thefuck --user

❯ pip show thefuck
Name: thefuck
Version: 3.32
Summary: Magnificent app which corrects your previous console command
Home-page: https://github.com/nvbn/thefuck
Author: Vladimir Iakovlev
Author-email: nvbn.rm@gmail.com
License: MIT
Location: /home/cs/.local/lib/python3.9/site-packages
Requires: colorama, decorator, psutil, pyte, six
Required-by:

❯ ls -l /home/cs/.local/bin | grep fuck
-rwxr-xr-x 1 cs cs 233 7月 16 23:28 fuck
-rwxr-xr-x 1 cs cs 223 7月 16 23:28 thefuck

1
2
3
4
5
❯ sudo ln -s /home/cs/.local/bin/thefuck /usr/local/bin/thefuck
[sudo] cs 的密码:
❯ sudo ln -s /home/cs/.local/bin/fuck /usr/local/bin/fuck


.zshrc

eval “$(/home/cs/.local/bin/thefuck –alias fuck)”

other

对于Zsh,这是一个语言级别的错误;对于Bash,这是一个外部命令执行的错误。这差别很重要,因为它意味着后者可以被轻易地catch,而前者不能。

zsh: no matches found:

find 命令

~/.zshrc中加入:setopt no_nomatch

带%

解决zsh不完全行会多%号的问题

unsetopt prompt_cr prompt_sp

zsh: 文件已存在:

默认情况下,Zsh不允许直接覆盖已存在的文件

1
2
# >! 都行
xsel -o -b >| /tmp/output.txt

>!的作用是强制覆盖已存在的文件/tmp/output.txt

点击打赏
文章目录
  1. 1. zsh
  2. 2. zimfw
    1. 2.1. Automatic installation
    2. 2.2. Manual installation
    3. 2.3. Uninstalling
  3. 3. modules
    1. 3.1. autojump
      1. 3.1.1. stat
    2. 3.2. fzf
    3. 3.3. fzf-tab
    4. 3.4. powerlevel10k
      1. 3.4.1. p10k安装
      2. 3.4.2. font
      3. 3.4.3. icons
    5. 3.5. exa
    6. 3.6. thefuck
  4. 4. other
    1. 4.1. zsh: no matches found:
    2. 4.2. 带%
    3. 4.3. zsh: 文件已存在:
载入天数...载入时分秒... ,