From b6923d4f35c3f2d00092cf366bc4d2e3b32dc790 Mon Sep 17 00:00:00 2001 From: gwbeip Date: Mon, 15 Jun 2026 19:39:59 +0800 Subject: [PATCH] refactor: remove hardcoded personal identifiers from tracked files --- README.md | 2 +- wsl/config_new_archlinux_in_wsl.md | 22 +++++++++++----------- zsh/zshenv | 15 ++++++++++++--- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 84a9ce7..aa6ae51 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Required software: `git`; `fzf`; `zoxide`; `python`; `starship` ```shell -git clone https://gitea.meip.work/gwbeip/TerminalPolyjuice.git $HOME/.TerminalPolyjuice +git clone $HOME/.TerminalPolyjuice cd $HOME/.TerminalPolyjuice/zsh zsh polyjuice.sh install_ohmyzsh config_starship check ``` diff --git a/wsl/config_new_archlinux_in_wsl.md b/wsl/config_new_archlinux_in_wsl.md index d1afc0b..458b41f 100755 --- a/wsl/config_new_archlinux_in_wsl.md +++ b/wsl/config_new_archlinux_in_wsl.md @@ -1,11 +1,11 @@ # Configure New Archlinux in WSL -## Add user `gwb` +## Add user `` ```shell cd pacman -Syu -useradd -m gwb +useradd -m ``` run @@ -16,11 +16,11 @@ to set a password for `root` run ```shell -passwd gwb +passwd ``` -to set a password for user `gwb` +to set a password for user `` -## Add user `gwb` into group `sudo` +## Add user `` into group `sudo` ```shell pacman -S sudo @@ -29,7 +29,7 @@ pacman -S vim edit `/etc/sudoers` uncomment `%wheel ALL=(ALL:ALL) ALL` ```shell -usermod -aG wheel gwb +usermod -aG wheel ``` ## Install and configure `ZSH` @@ -41,12 +41,12 @@ pacman -S fzf pacman -S zoxide pacman -S starship pacman -S python -su gwb +su cd -git clone https://gitea.meip.work/gwbeip/TerminalPolyjuice.git $HOME/.TerminalPolyjuice +git clone $HOME/.TerminalPolyjuice chsh -s /bin/zsh exit -su gwb +su cd mkdir .config cd $HOME/.TerminalPolyjuice/zsh @@ -55,7 +55,7 @@ zsh polyjuice.sh install_ohmyzsh config_starship check add the contents in `$HOME/.TerminalPolyjuice/zsh/zshenv` into `$HOME/.zshenv` -# Set `gwb` as default user +# Set `` as default user ```shell -wsl --manage archlinux --set-default-user gwb +wsl --manage archlinux --set-default-user ``` diff --git a/zsh/zshenv b/zsh/zshenv index cd317cb..1c7bc13 100644 --- a/zsh/zshenv +++ b/zsh/zshenv @@ -1,7 +1,16 @@ # "[interop] appendWindowsPath=false" in /etc/wsl.conf is setted -# Append VSCode on Windows into PATH so that vscode can be used in WSL -export PATH=$PATH:'/mnt/c/Users/gwbei/AppData/Local/Programs/Microsoft VS Code/bin/' -export PATH=$PATH:'/mnt/c/Users/gwbei/AppData/Local/Programs/Zed/bin/zed' +# Dynamically resolve Windows-side program paths (avoids hardcoding usernames) +if [[ -n "$WSLENV" ]]; then + _win_user=$(cmd.exe /c "echo %USERNAME%" 2>/dev/null | tr -d '\r\n') + if [[ -n "$_win_user" ]]; then + _win_home="/mnt/c/Users/$_win_user" + _vscode_bin="$_win_home/AppData/Local/Programs/Microsoft VS Code/bin" + _zed_bin="$_win_home/AppData/Local/Programs/Zed/bin" + [[ -d "$_vscode_bin" ]] && export PATH="$PATH:$_vscode_bin" + [[ -d "$_zed_bin" ]] && export PATH="$PATH:$_zed_bin" + fi + unset _win_user _win_home _vscode_bin _zed_bin +fi # Language and encoding related export LC_ALL=C.UTF-8