fix(zsh): load iTerm2 integration from user config

This commit is contained in:
Konano 2026-09-27 22:55:00 +08:00
parent ebffc87b78
commit 364fe2381f
4 changed files with 8 additions and 22 deletions

View File

@ -207,6 +207,7 @@ configure_zsh() {
cp $scriptdir/files/zsh/51-alias.zsh ~/.oh-my-zsh/custom/
cp $scriptdir/files/zsh/90-other.zsh ~/.oh-my-zsh/custom/
cp $scriptdir/files/zsh/ys-simple.zsh-theme ~/.oh-my-zsh/custom/themes/
cp $scriptdir/files/zsh/iterm2_shell_integration.zsh ~/.iterm2_shell_integration.zsh
[ $abroad -eq 1 ] && return
cp $scriptdir/files/zsh/80-proxy.zsh ~/.oh-my-zsh/custom/

View File

@ -1,5 +1,7 @@
__zsh_clash_env_unset
__zsh_load_iterm2_shell_integration
# HOST="VM-ubuntu"
# ZSH_THEME="robbyrussell"

View File

@ -60,6 +60,10 @@ __zsh_clash_env_unset() {
unset all_proxy
}
__zsh_load_iterm2_shell_integration() {
[ -r "$HOME/.iterm2_shell_integration.zsh" ] && source "$HOME/.iterm2_shell_integration.zsh"
}
__zsh_history_remove() {
if [ -z "$1" ]; then
echo "Please specify a keyword to remove"

View File

@ -37,27 +37,6 @@ update_authorized_keys() {
done <<< "$public_keys"
}
update_iterm2_shell_integration() {
local iterm2_script="$HOME/.iterm2_shell_integration.zsh"
local bundled_script="$scriptdir/files/zsh/iterm2_shell_integration.zsh"
local tmp_script
local source_line='[ -r "$HOME/.iterm2_shell_integration.zsh" ] && source "$HOME/.iterm2_shell_integration.zsh"'
if [ ! -s "$iterm2_script" ]; then
tmp_script=$(mktemp "$HOME/.iterm2_shell_integration.zsh.XXXXXX") || return
if [ "${offline:-0}" = 1 ] || ! command -v curl >/dev/null 2>&1 ||
! curl -fsSL -m 15 "https://iterm2.com/shell_integration/zsh" -o "$tmp_script" || [ ! -s "$tmp_script" ]; then
cp "$bundled_script" "$tmp_script" || { rm -f "$tmp_script"; return 1; }
fi
mv -f "$tmp_script" "$iterm2_script" || { rm -f "$tmp_script"; return 1; }
fi
touch "$HOME/.zshrc" || return
if ! grep -Fxq "$source_line" "$HOME/.zshrc"; then
printf '\n%s\n' "$source_line" >>"$HOME/.zshrc"
fi
}
# ============================================================
update_file $scriptdir/files/.nanorc ~/.nanorc
@ -72,8 +51,8 @@ update_file $scriptdir/files/zsh/51-alias.zsh ~/.oh-my-zsh/custom/51-a
update_file $scriptdir/files/zsh/80-proxy.zsh ~/.oh-my-zsh/custom/80-proxy.zsh
update_file $scriptdir/files/zsh/90-other.zsh ~/.oh-my-zsh/custom/90-other.zsh
update_file $scriptdir/files/zsh/ys-simple.zsh-theme ~/.oh-my-zsh/custom/themes/ys-simple.zsh-theme
update_file $scriptdir/files/zsh/iterm2_shell_integration.zsh ~/.iterm2_shell_integration.zsh
update_authorized_keys
update_iterm2_shell_integration
# sudo_id=$(sudo id -u 2>/dev/null)
# if [ $? -eq 0 ] && [ "$sudo_id" -eq 0 ]; then