From 6ff9206cec3d8f818c9829f608ffb264ce368855 Mon Sep 17 00:00:00 2001 From: smeb y <48400087+a3165458@users.noreply.github.com> Date: Sun, 17 Mar 2024 12:15:53 +0800 Subject: [PATCH] Update Quili.sh --- Quili.sh | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/Quili.sh b/Quili.sh index 4a9fe2a..c552021 100644 --- a/Quili.sh +++ b/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 }