55 lines
2.2 KiB
Fish
55 lines
2.2 KiB
Fish
if status is-interactive
|
||
# ========= 编辑器环境变量设置 ==========
|
||
set -l editor_cmd (if type -q vim; echo vim; else if type -q vi; echo vi; else; end)
|
||
test -n "$editor_cmd"; and set -gx EDITOR $editor_cmd
|
||
test -n "$editor_cmd"; and set -gx VISUAL $editor_cmd
|
||
|
||
# ========= Bash 常用命令增强/替代 ==========
|
||
# 工具选择
|
||
set -l ls_cmd (if type -q eza; echo eza; else if type -q exa; echo exa; else; end)
|
||
set -l cat_cmd (if type -q bat; echo bat; else if type -q batcat; echo batcat; else; end)
|
||
set -l find_cmd (if type -q fd; echo fd; else if type -q fdfind; echo fdfind; else; end)
|
||
|
||
# 处理特殊情况:根据选择的工具添加缩写
|
||
test "$cat_cmd" = "batcat"; and abbr bat batcat
|
||
test "$find_cmd" = "fdfind"; and abbr fd fdfind
|
||
|
||
# 使用 zoxide init 添加 cd 和 cdi 命令
|
||
type -q zoxide; and zoxide init --cmd cd fish | source
|
||
|
||
# 命令缩写配置
|
||
test -n "$ls_cmd"; and abbr ls $ls_cmd
|
||
test -n "$ls_cmd"; and abbr ll "$ls_cmd -l"
|
||
test -n "$ls_cmd"; and abbr la "$ls_cmd -a"
|
||
test -n "$ls_cmd"; and abbr lal "$ls_cmd -la"
|
||
test -n "$cat_cmd"; and abbr cat $cat_cmd
|
||
test -n "$cat_cmd"; and abbr cap "$cat_cmd -p"
|
||
test -n "$find_cmd"; and abbr find $find_cmd
|
||
type -q rg; and abbr grep rg
|
||
type -q btop; and abbr top btop
|
||
type -q tldr; and abbr help tldr
|
||
|
||
# ========= 其他工具配置 ==========
|
||
type -q chezmoi; and abbr cz chezmoi
|
||
type -q tmux; and abbr tm tmux
|
||
type -q tmux; and abbr tmn 'tmux new'
|
||
type -q tmux; and abbr tma 'tmux attach'
|
||
type -q tmux; and abbr tml 'tmux list-sessions'
|
||
type -q docker; and abbr d docker
|
||
type -q docker-compose; and abbr dc 'docker-compose'
|
||
|
||
# systemd 常用缩写
|
||
type -q systemctl; and abbr sc systemctl
|
||
type -q systemctl; and abbr scu 'systemctl --user'
|
||
type -q journalctl; and abbr jc journalctl
|
||
type -q journalctl; and abbr jcu 'journalctl --user'
|
||
|
||
# ========= thefuck:自动命令纠错 =========
|
||
type -q thefuck; and thefuck --alias | source
|
||
|
||
# ========= fastfetch:启动信息显示(仅在第一次打开 shell 时) =========
|
||
if status --is-login; and type -q fastfetch
|
||
fastfetch
|
||
end
|
||
end
|