Update Quili.sh
This commit is contained in:
parent
aa317cc7a4
commit
6ff9206cec
21
Quili.sh
21
Quili.sh
@ -6,25 +6,18 @@ SCRIPT_PATH="$HOME/Quili.sh"
|
||||
# 自动设置快捷键的功能
|
||||
function check_and_set_alias() {
|
||||
local alias_name="quili"
|
||||
local shell_rc="$HOME/.bashrc"
|
||||
|
||||
# 对于Zsh用户,使用.zshrc
|
||||
if [ -n "$ZSH_VERSION" ]; then
|
||||
shell_rc="$HOME/.zshrc"
|
||||
elif [ -n "$BASH_VERSION" ]; then
|
||||
shell_rc="$HOME/.bashrc"
|
||||
fi
|
||||
local profile_file="$HOME/.profile"
|
||||
|
||||
# 检查快捷键是否已经设置
|
||||
if ! grep -q "$alias_name" "$shell_rc"; then
|
||||
echo "设置快捷键 '$alias_name' 到 $shell_rc"
|
||||
echo "alias $alias_name='bash $SCRIPT_PATH'" >> "$shell_rc"
|
||||
if ! grep -q "$alias_name" "$profile_file"; then
|
||||
echo "设置快捷键 '$alias_name' 到 $profile_file"
|
||||
echo "alias $alias_name='bash $SCRIPT_PATH'" >> "$profile_file"
|
||||
# 添加提醒用户激活快捷键的信息
|
||||
echo "快捷键 '$alias_name' 已设置。请运行 'source $shell_rc' 来激活快捷键,或重新打开终端。"
|
||||
echo "快捷键 '$alias_name' 已设置。请运行 'source $profile_file' 来激活快捷键,或重新登录。"
|
||||
else
|
||||
# 如果快捷键已经设置,提供一个提示信息
|
||||
echo "快捷键 '$alias_name' 已经设置在 $shell_rc。"
|
||||
echo "如果快捷键不起作用,请尝试运行 'source $shell_rc' 或重新打开终端。"
|
||||
echo "快捷键 '$alias_name' 已经设置在 $profile_file。"
|
||||
echo "如果快捷键不起作用,请尝试运行 'source $profile_file' 或重新登录。"
|
||||
fi
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user