一、FIsh 的安装与简单配置
1
2
3
4
5
|
# 完整的Linux系统请使用fish真实路径
chsh -s $(which fish)
# termux设为默认shell
chsh -s fish
|
1
|
fish -c "set -U fish_greeting"
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
mkdir -p ~/.config/fish
# fish 的配置文件
cat > ~/.config/fish/config.fish <<EOF
alias apti='apt -y install'
alias aptr='apt -y remove'
alias apts='apt search'
alias aa='apt update -y ; apt upgrade -y ; apt autoremove -y'
alias lsa='ls -a'
alias ..='cd ..; ls -a'
alias ll='ls -al'
alias gitc='git clone'
alias gitp='git add . ; git commit -m auto-push ; git push ; echo push成功'
alias myip='curl ifconfig.me'
EOF
|
1
2
3
4
5
|
# 定义变量
set t 123 # 相当于bash的 t=123
# 括号内执行
grep 1 (ls) # 相当于bash的 grep 1 $(ls)
|
1
2
3
4
5
6
7
|
if grep fish /etc/shells
echo Found fish
else if grep bash /etc/shells
echo Found bash
else
echo Got nothing
end
|
1
2
3
4
5
6
7
8
9
10
|
switch (uname)
case Linux
echo Hi Tux!
case Darwin
echo Hi Hexley!
case FreeBSD NetBSD DragonFly
echo Hi Beastie!
case '*'
echo Hi, stranger!
end
|
1
2
3
|
while true
echo "Loop forever"
end
|
1
2
3
|
for file in *.txt
cp $file $file.bak
end
|
- Fish 的函数用来封装命令,或者为现有的命令起别名。
1
2
3
|
function ll
ls -lhG $argv
end
|
上面代码定义了一个ll
函数。命令行执行这个函数以后,就可以用ll
命令替代ls -lhG
。其中,变量$argv
表示函数的参数。
下面是另一个例子。
1
2
3
|
function ls
command ls -hG $argv
end
|
以上引用于阮一峰的 Fish shell 入门教程
二、Oh-my-fish 的安装与简单用法
1
|
curl -L https://get.oh-my.fish | fish
|
1
2
3
4
5
6
7
8
9
10
|
# 列出已安装的和可安装的主题
omf theme
# 安装 ays 主题
omf install ays
# 更换主题为已安装的 cbjohnson 主题
omf theme cbjohnson
# 检查 omf 是否有错误
omf doctor
# 卸载 omf
omf destroy
|
注意
文章最下方有所有主题的截图,完全是手工截图,真的是累啊
三、Fish 与 Oh-my-fish 的卸载与清理配置文件
注意
卸载 Fish
之前建议先卸载 Oh-my-fish
1
2
3
|
# fish 环境下运行以下命令
omf destroy
rm -r (find ~ -name omf)
|
注意
卸载 Fish
之前一定要修改当前默认shell不是fish
1
2
3
4
5
6
7
8
9
|
# 修改默认终端为bash
chsh -s $(which bash) # Linux 系统
chsh -s bash # Termux
# 完全卸载fish
# bash 环境下运行
apt purge -y fish
apt autoremove
rm -r $(find ~ -name fish)
|
四、Oh-my-fish 的所有主题截图
注意
以下是在WSL的Ubuntu20 下的效果,如果你也是,但凡我标注了Error
的主题,请不要尝试
- 我之前用的是
ays
主题,现在用的是numist
主题
1 agnoster
2 aight
3 ays
4 barracuda(termux专用)
5 batman
6 beloglazov
7 bira
8 bobthefish
9 bongnoster
10 boxfish
11 budspencer
12 cbjohnson
13 chain
14 clearance
15 cmorrell
16 coffeeandcode
17 cor (emoji-clock Error)
18 cyan (math: Error)
19 dangerous ( [I] 提示)
20 default
21 dmorrell
22 doughsay
23 eclm
24 edan
25 eden
26 emoji-powerline
27 es
28 fishbone
29 fishface
30 fishy-drupal
31 fisk
32 flash
33 fox
34 gentoo
35 gianu
36 gitstatus
37 gnuykeaj
38 godfather
39 graystatus
40 harleen
41 idan
42 integral
43 jacaetevha
44 johanson
45 kawasaki
46 krisleech
47 l
48 lambda
49 lavender
50 lolfish
51 mars
52 mish
53 mokou
54 mtahmed
55 nai
56 nelsonjchen
57 neolambda
58 numist
59 ocean
60 one
61 pastfish
62 perryh
63 pie (Error)
64 plain (Error)
65 pure
66 pygmalion
67 random
68 randomrussel
69 redfish
70 red-snapper
71 rider
72 robbyrussell
73 sashimi
74 scorphish
75 separation
76 shellder
77 simple-ass-prompt
78 simplevi
79 slacker
80 slavic-cat
81 solarfish
82 spacefish
83 sushi
84 syl20bnr
85 taktoa
86 technopagan (moonmoji Error)
87 toaster
88 tomita
89 trout (有点慢,需要安装rbenv)
91 uggedal
92 will
93 wolf-theme
94 yimmy
95 zeit
96 zephyr
97 zish