Bash配置文件
Apr 04, 2026·1 min read·195 words
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific environment
if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]]; then
PATH="$HOME/.local/bin:$HOME/bin:$PATH"
fi
export PATH
# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=
# User specific aliases and functions
if [ -d ~/.bashrc.d ]; then
for rc in ~/.bashrc.d/*; do
if [ -f "$rc" ]; then
. "$rc"
fi
done
fi
unset rc
[ ! -f "$HOME/.x-cmd.root/X" ] || . "$HOME/.x-cmd.root/X" # boot up x-cmd.
# 添加到 ~/.bashrc
# y 别名 - 打开 yazi,退出后返回原目录
# alias y='yazi'
# dow 别名 - 进入 Downloads 目录并显示内容
alias dl='cd ~/Downloads'
alias blog='cd ~/lkfblog/content/posts'
y() {
local cwd_file="/tmp/yazi-cwd-$$"
yazi --cwd-file="$cwd_file"
if [ -f "$cwd_file" ]; then
local new_dir=$(cat "$cwd_file")
if [ -d "$new_dir" ]; then
cd "$new_dir"
fi
rm -f "$cwd_file"
fi
}
alias sdi='sudo dnf install'
alias sdu='sudo dnf update'
alias sdc='sudo dnf clean all'
alias sdr='sudo dnf remove'
alias zj='zellij'
export PATH="$HOME/bin:$PATH"
export PATH="$HOME/.cargo/bin:$PATH"
. "$HOME/.cargo/env"