Skip to content

Commit

Permalink
fix: Can not enable proxy for non-root user (SukkaW#21)
Browse files Browse the repository at this point in the history
The plugin tries to enable apt proxy, but it is not support to use apt for non-root users, so as the proxy for apt. I only determine if the current user has sudo privileges. If the user does not have sudo privileges, the proxy will not be set for apt.
  • Loading branch information
lyx10101010 committed Jun 5, 2024
1 parent 2ec61be commit 071b4f9
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions zsh-proxy.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,9 @@ __enable_proxy() {
__disable_proxy_all
__disable_proxy_git
__disable_proxy_npm
__disable_proxy_apt
if sudo -n true 2>/dev/null; then
__disable_proxy_apt
fi
echo "Done!"
echo "----------------------------------------"
echo "Enable proxy for:"
Expand All @@ -255,7 +257,10 @@ __enable_proxy() {
# npm & yarn & pnpm"
__enable_proxy_npm
# apt"
__enable_proxy_apt
if sudo -n true 2>/dev/null; then
echo "- apt"
__enable_proxy_apt
fi
echo "Done!"
fi
}
Expand All @@ -264,7 +269,9 @@ __disable_proxy() {
__disable_proxy_all
__disable_proxy_git
__disable_proxy_npm
__disable_proxy_apt
if sudo -n true 2>/dev/null; then
__disable_proxy_apt
fi
}

__auto_proxy() {
Expand Down

0 comments on commit 071b4f9

Please sign in to comment.