summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Cornellà <hello@mcornella.com>2021-03-25 12:08:00 +0100
committerMarc Cornellà <hello@mcornella.com>2021-03-25 12:08:00 +0100
commit02d07f3e3dba0d50b1d907a8062bbaca18f88478 (patch)
treecbac73b3b000eb85971f0f37ab2dfea3334cd05d
parent95a06f3927a286db257dc99791b02caba757fe33 (diff)
downloadzsh-02d07f3e3dba0d50b1d907a8062bbaca18f88478.tar.gz
zsh-02d07f3e3dba0d50b1d907a8062bbaca18f88478.tar.bz2
zsh-02d07f3e3dba0d50b1d907a8062bbaca18f88478.zip
fix: use `$USERNAME` guaranteed to always be defined in zsh
Fixes #9701
-rw-r--r--lib/completion.zsh4
-rw-r--r--lib/diagnostics.zsh2
-rwxr-xr-xplugins/emacs/emacsclient.sh4
-rw-r--r--plugins/screen/screen.plugin.zsh4
-rw-r--r--plugins/ssh-agent/ssh-agent.plugin.zsh4
-rw-r--r--plugins/systemadmin/README.md22
-rw-r--r--plugins/systemadmin/systemadmin.plugin.zsh2
-rw-r--r--themes/adben.zsh-theme4
-rw-r--r--themes/agnoster.zsh-theme2
-rw-r--r--themes/avit.zsh-theme2
-rw-r--r--themes/flazz.zsh-theme2
-rw-r--r--themes/obraun.zsh-theme2
-rw-r--r--themes/re5et.zsh-theme2
-rw-r--r--themes/sunrise.zsh-theme2
-rwxr-xr-xtools/install.sh2
15 files changed, 30 insertions, 30 deletions
diff --git a/lib/completion.zsh b/lib/completion.zsh
index 2b62785d5..ebaab0856 100644
--- a/lib/completion.zsh
+++ b/lib/completion.zsh
@@ -32,9 +32,9 @@ zstyle ':completion:*' list-colors ''
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
if [[ "$OSTYPE" = solaris* ]]; then
- zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm"
+ zstyle ':completion:*:*:*:*:processes' command "ps -u $USERNAME -o pid,user,comm"
else
- zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm -w -w"
+ zstyle ':completion:*:*:*:*:processes' command "ps -u $USERNAME -o pid,user,comm -w -w"
fi
# disable named-directories autocompletion
diff --git a/lib/diagnostics.zsh b/lib/diagnostics.zsh
index 001de42b7..650520797 100644
--- a/lib/diagnostics.zsh
+++ b/lib/diagnostics.zsh
@@ -112,7 +112,7 @@ function _omz_diag_dump_one_big_text() {
command uname -a
builtin echo OSTYPE=$OSTYPE
builtin echo ZSH_VERSION=$ZSH_VERSION
- builtin echo User: $USER
+ builtin echo User: $USERNAME
builtin echo umask: $(umask)
builtin echo
_omz_diag_dump_os_specific_version
diff --git a/plugins/emacs/emacsclient.sh b/plugins/emacs/emacsclient.sh
index 0aa8d6f40..04a2c2afd 100755
--- a/plugins/emacs/emacsclient.sh
+++ b/plugins/emacs/emacsclient.sh
@@ -20,8 +20,8 @@ _emacsfun()
# tempfile. (first argument will be `--no-wait` passed in by the plugin.zsh)
if [ "$#" -ge "2" -a "$2" = "-" ]
then
- tempfile="$(mktemp --tmpdir emacs-stdin-$USER.XXXXXXX 2>/dev/null \
- || mktemp -t emacs-stdin-$USER)" # support BSD mktemp
+ tempfile="$(mktemp --tmpdir emacs-stdin-$USERNAME.XXXXXXX 2>/dev/null \
+ || mktemp -t emacs-stdin-$USERNAME)" # support BSD mktemp
cat - > "$tempfile"
_emacsfun --no-wait $tempfile
else
diff --git a/plugins/screen/screen.plugin.zsh b/plugins/screen/screen.plugin.zsh
index 7009e7a91..c1db8ad92 100644
--- a/plugins/screen/screen.plugin.zsh
+++ b/plugins/screen/screen.plugin.zsh
@@ -2,7 +2,7 @@
# of the tab window should be.
if [[ "$TERM" == screen* ]]; then
if [[ $_GET_PATH == '' ]]; then
- _GET_PATH='echo $PWD | sed "s/^\/Users\//~/;s/^\/home\//~/;s/^~$USER/~/"'
+ _GET_PATH='echo $PWD | sed "s/^\/Users\//~/;s/^\/home\//~/;s/^~$USERNAME/~/"'
fi
if [[ $_GET_HOST == '' ]]; then
_GET_HOST='echo $HOST | sed "s/\..*//"'
@@ -51,4 +51,4 @@ if [[ "$TERM" == screen* ]]; then
eval "tab_hardstatus=$TAB_HARDSTATUS_PREFIX:$TAB_HARDSTATUS_PROMPT"
screen_set $tab_title $tab_hardstatus
}
-fi \ No newline at end of file
+fi
diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh
index 430647135..d45406f63 100644
--- a/plugins/ssh-agent/ssh-agent.plugin.zsh
+++ b/plugins/ssh-agent/ssh-agent.plugin.zsh
@@ -61,11 +61,11 @@ zstyle -b :omz:plugins:ssh-agent agent-forwarding _agent_forwarding
if [[ $_agent_forwarding == "yes" && -n "$SSH_AUTH_SOCK" ]]; then
# Add a nifty symlink for screen/tmux if agent forwarding
- [[ -L $SSH_AUTH_SOCK ]] || ln -sf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USER-screen
+ [[ -L $SSH_AUTH_SOCK ]] || ln -sf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USERNAME-screen
elif [[ -f "$_ssh_env_cache" ]]; then
# Source SSH settings, if applicable
. $_ssh_env_cache > /dev/null
- if [[ $USER == "root" ]]; then
+ if [[ $USERNAME == "root" ]]; then
FILTER="ax"
else
FILTER="x"
diff --git a/plugins/systemadmin/README.md b/plugins/systemadmin/README.md
index 243db03f2..052fc6edc 100644
--- a/plugins/systemadmin/README.md
+++ b/plugins/systemadmin/README.md
@@ -10,17 +10,17 @@ plugins=(... systemadmin)
## Aliases
-| Alias | Command | Description |
-|---------|------------------------------------------------------------------------|--------------------------------------------------------------------|
-| ping | `ping -c 5` | Sends only 5 ICMP Messages |
-| clr | `clear; echo Currently logged in on $TTY, as $USER in directory $PWD.` | Clears the screen and prints the current user, TTY, and directory |
-| path | `print -l $path` | Displays PATH with each entry on a separate line |
-| mkdir | `mkdir -pv` | Automatically create parent directories and display verbose output |
-| psmem | `ps -e -orss=,args= \| sort -b -k1 -nr` | Display the processes using the most memory |
-| psmem10 | `ps -e -orss=,args= \| sort -b -k1 -nr \| head -10` | Display the top 10 processes using the most memory |
-| pscpu | `ps -e -o pcpu,cpu,nice,state,cputime,args \|sort -k1 -nr` | Display the top processes using the most CPU |
-| pscpu10 | `ps -e -o pcpu,cpu,nice,state,cputime,args \|sort -k1 -nr \| head -10` | Display the top 10 processes using the most CPU |
-| hist10 | `print -l ${(o)history%% *} \| uniq -c \| sort -nr \| head -n 10` | Display the top 10 most used commands in the history |
+| Alias | Command | Description |
+|---------|----------------------------------------------------------------------------|--------------------------------------------------------------------|
+| ping | `ping -c 5` | Sends only 5 ICMP Messages |
+| clr | `clear; echo Currently logged in on $TTY, as $USERNAME in directory $PWD.` | Clears the screen and prints the current user, TTY, and directory |
+| path | `print -l $path` | Displays PATH with each entry on a separate line |
+| mkdir | `mkdir -pv` | Automatically create parent directories and display verbose output |
+| psmem | `ps -e -orss=,args= \| sort -b -k1 -nr` | Display the processes using the most memory |
+| psmem10 | `ps -e -orss=,args= \| sort -b -k1 -nr \| head -10` | Display the top 10 processes using the most memory |
+| pscpu | `ps -e -o pcpu,cpu,nice,state,cputime,args \|sort -k1 -nr` | Display the top processes using the most CPU |
+| pscpu10 | `ps -e -o pcpu,cpu,nice,state,cputime,args \|sort -k1 -nr \| head -10` | Display the top 10 processes using the most CPU |
+| hist10 | `print -l ${(o)history%% *} \| uniq -c \| sort -nr \| head -n 10` | Display the top 10 most used commands in the history |
## Functions
diff --git a/plugins/systemadmin/systemadmin.plugin.zsh b/plugins/systemadmin/systemadmin.plugin.zsh
index 03064c035..08136abda 100644
--- a/plugins/systemadmin/systemadmin.plugin.zsh
+++ b/plugins/systemadmin/systemadmin.plugin.zsh
@@ -21,7 +21,7 @@ function retlog() {
}
alias ping='ping -c 5'
-alias clr='clear; echo Currently logged in on $TTY, as $USER in directory $PWD.'
+alias clr='clear; echo Currently logged in on $TTY, as $USERNAME in directory $PWD.'
alias path='print -l $path'
alias mkdir='mkdir -pv'
# get top process eating memory
diff --git a/themes/adben.zsh-theme b/themes/adben.zsh-theme
index b9ac77d00..7321df724 100644
--- a/themes/adben.zsh-theme
+++ b/themes/adben.zsh-theme
@@ -89,8 +89,8 @@ function precmd {
# Context: user@directory or just directory
prompt_context () {
- if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
- echo -n "${PR_RESET}${PR_RED}$USER@%m${PR_RESET}${PR_BRIGHT_YELLOW}%~%<<${PR_RESET}"
+ if [[ "$USERNAME" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
+ echo -n "${PR_RESET}${PR_RED}$USERNAME@%m${PR_RESET}${PR_BRIGHT_YELLOW}%~%<<${PR_RESET}"
else
echo -n "${PR_RESET}${PR_BRIGHT_YELLOW}%~%<<${PR_RESET}"
fi
diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme
index 99707f684..fe7ddbac6 100644
--- a/themes/agnoster.zsh-theme
+++ b/themes/agnoster.zsh-theme
@@ -88,7 +88,7 @@ prompt_end() {
# Context: user@hostname (who am I and where am I)
prompt_context() {
- if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
+ if [[ "$USERNAME" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
prompt_segment black default "%(!.%{%F{yellow}%}.)%n@%m"
fi
}
diff --git a/themes/avit.zsh-theme b/themes/avit.zsh-theme
index 921ed99d3..1e20d8f9f 100644
--- a/themes/avit.zsh-theme
+++ b/themes/avit.zsh-theme
@@ -17,7 +17,7 @@ function _user_host() {
local me
if [[ -n $SSH_CONNECTION ]]; then
me="%n@%m"
- elif [[ $LOGNAME != $USER ]]; then
+ elif [[ $LOGNAME != $USERNAME ]]; then
me="%n"
fi
if [[ -n $me ]]; then
diff --git a/themes/flazz.zsh-theme b/themes/flazz.zsh-theme
index c0a7fb5d0..e21b52ef5 100644
--- a/themes/flazz.zsh-theme
+++ b/themes/flazz.zsh-theme
@@ -1,4 +1,4 @@
-if [ "$USER" = "root" ]
+if [ "$USERNAME" = "root" ]
then CARETCOLOR="red"
else CARETCOLOR="blue"
fi
diff --git a/themes/obraun.zsh-theme b/themes/obraun.zsh-theme
index 7af44056f..cc2769e4b 100644
--- a/themes/obraun.zsh-theme
+++ b/themes/obraun.zsh-theme
@@ -1,4 +1,4 @@
-if [ "$USER" = "root" ]; then CARETCOLOR="red"; else CARETCOLOR="blue"; fi
+if [ "$USERNAME" = "root" ]; then CARETCOLOR="red"; else CARETCOLOR="blue"; fi
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
diff --git a/themes/re5et.zsh-theme b/themes/re5et.zsh-theme
index 95af1e2ee..bdf342f49 100644
--- a/themes/re5et.zsh-theme
+++ b/themes/re5et.zsh-theme
@@ -1,4 +1,4 @@
-if [ "$USER" = "root" ]; then CARETCOLOR="red"; else CARETCOLOR="magenta"; fi
+if [ "$USERNAME" = "root" ]; then CARETCOLOR="red"; else CARETCOLOR="magenta"; fi
local return_code="%(?..%{$fg_bold[red]%}:( %?%{$reset_color%})"
diff --git a/themes/sunrise.zsh-theme b/themes/sunrise.zsh-theme
index 2111576c3..11f6af127 100644
--- a/themes/sunrise.zsh-theme
+++ b/themes/sunrise.zsh-theme
@@ -9,7 +9,7 @@ Y=$fg_no_bold[yellow]
B=$fg_no_bold[blue]
RESET=$reset_color
-if [ "$USER" = "root" ]; then
+if [ "$USERNAME" = "root" ]; then
PROMPTCOLOR="%{$R%}" PROMPTPREFIX="-!-";
else
PROMPTCOLOR="" PROMPTPREFIX="---";
diff --git a/tools/install.sh b/tools/install.sh
index d4ecb7afe..cfc2808fe 100755
--- a/tools/install.sh
+++ b/tools/install.sh
@@ -227,7 +227,7 @@ EOF
if [ -n "$SHELL" ]; then
echo "$SHELL" > ~/.shell.pre-oh-my-zsh
else
- grep "^$USER:" /etc/passwd | awk -F: '{print $7}' > ~/.shell.pre-oh-my-zsh
+ grep "^$USERNAME:" /etc/passwd | awk -F: '{print $7}' > ~/.shell.pre-oh-my-zsh
fi
# Actually change the default shell to zsh