Fish配置文件|config.fish
介绍-1.0
这个fish配置是模仿我之前的bash配置的,但是没能完成耗时。但是不加也无所谓~
实际代码
请放置于~/.config/fish/config.fish!
############################## 自定义 ##############################
## 变量
# 如果使用 opkg,添加以下内容
# set -x PATH $PATH /opt/bin
# ----- 备忘录 -----
set memo /home/xue/文档/memo.xue
## 别名
alias ls="ls --color -F"
alias lah="ls --color -lFah"
alias ll="ls --color -Flh"
alias cat="cat -T"
alias less="less -R"
if test -e $memo
alias memo="lolcat $memo"
else
alias memo="echo 备忘录路径为空!请手动添加到 config.fish!"
end
# 为了方便的 irssi
alias irssi="irssi -c irc.rizon.net"
alias d--="c++ -x cpp"
# thefuck
if type -q thefuck
thefuck --alias ah | source
end
####################################################################
# 增强版 Fish Shell 提示符
function fish_prompt
# 保存上一个命令的退出状态
set -l last_status $status
# 颜色定义
set -l user_color (set_color -o blue)
if test (id -u) -eq 0
set user_color (set_color -o red)
end
set -l host_color (set_color -o yellow)
set -l path_color (set_color -o cyan)
set -l git_color (set_color -o green)
set -l success_color (set_color -o green)
set -l error_color (set_color -o red)
set -l prompt_color (set_color -o white)
set -l time_color (set_color -o purple)
set -l reset (set_color normal)
# 获取 Git 分支信息
set -l git_branch
if type -q git
set git_branch (git branch --show-current 2>/dev/null)
if test -n "$git_branch"
set git_branch " | $git_branch"
end
end
# 构建提示符
echo -n "╭─"
echo -n "["
echo -n "$user_color"(whoami)"$reset"
echo -n "@$host_color"(hostname -s)"$reset"
echo -n ":$path_color"(prompt_pwd)"$reset"
if test -n "$git_branch"
echo -n "$git_color$git_branch$reset"
end
echo -n "]"
# 命令状态指示 - 现在会正确显示错误状态
if test $last_status -eq 0
echo -n " $success_color✓$reset"
else
echo -n " $error_color✗($last_status)$reset"
end
# 添加当前时间和命令执行时间
echo -n " "(date "+%T")" "
echo ""
echo -n "╰─$prompt_color"
if test (id -u) -eq 0
echo -n "#"
else
echo -n "\$"
end
echo -n "$path_color>$reset "
end

浙公网安备 33010602011771号