Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Ohmyzsh
Commits
02d07f3e
Unverified
Commit
02d07f3e
authored
Mar 25, 2021
by
Marc Cornellà
Browse files
fix: use `$USERNAME` guaranteed to always be defined in zsh
Fixes #9701
parent
95a06f39
Changes
15
Hide whitespace changes
Inline
Side-by-side
lib/completion.zsh
View file @
02d07f3e
...
...
@@ -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
$USER
NAME
-o pid,user,comm"
else
zstyle
':completion:*:*:*:*:processes'
command
"ps -u
$USER
-o pid,user,comm -w -w"
zstyle
':completion:*:*:*:*:processes'
command
"ps -u
$USER
NAME
-o pid,user,comm -w -w"
fi
# disable named-directories autocompletion
...
...
lib/diagnostics.zsh
View file @
02d07f3e
...
...
@@ -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:
$USER
NAME
builtin echo umask
:
$(
umask
)
builtin echo
_omz_diag_dump_os_specific_version
...
...
plugins/emacs/emacsclient.sh
View file @
02d07f3e
...
...
@@ -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-
$USER
NAME
.XXXXXXX 2>/dev/null
\
||
mktemp
-t
emacs-stdin-
$USER
NAME
)
"
# support BSD mktemp
cat
-
>
"
$tempfile
"
_emacsfun
--no-wait
$tempfile
else
...
...
plugins/screen/screen.plugin.zsh
View file @
02d07f3e
...
...
@@ -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/^~$USER
NAME
/~/"'
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
plugins/ssh-agent/ssh-agent.plugin.zsh
View file @
02d07f3e
...
...
@@ -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-
$USER
NAME
-screen
elif
[[
-f
"
$_ssh_env_cache
"
]]
;
then
# Source SSH settings, if applicable
.
$_ssh_env_cache
>
/dev/null
if
[[
$USER
==
"root"
]]
;
then
if
[[
$USER
NAME
==
"root"
]]
;
then
FILTER
=
"ax"
else
FILTER
=
"x"
...
...
plugins/systemadmin/README.md
View file @
02d07f3e
...
...
@@ -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 $USER
NAME
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
...
...
plugins/systemadmin/systemadmin.plugin.zsh
View file @
02d07f3e
...
...
@@ -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 $USER
NAME
in directory $PWD.'
alias
path
=
'print -l $path'
alias mkdir
=
'mkdir -pv'
# get top process eating memory
...
...
themes/adben.zsh-theme
View file @
02d07f3e
...
...
@@ -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
[[
"
$USER
NAME
"
!=
"
$DEFAULT_USER
"
||
-n
"
$SSH_CLIENT
"
]]
;
then
echo
-n
"
${
PR_RESET
}${
PR_RED
}
$USER
NAME
@%m
${
PR_RESET
}${
PR_BRIGHT_YELLOW
}
%~%<<
${
PR_RESET
}
"
else
echo
-n
"
${
PR_RESET
}${
PR_BRIGHT_YELLOW
}
%~%<<
${
PR_RESET
}
"
fi
...
...
themes/agnoster.zsh-theme
View file @
02d07f3e
...
...
@@ -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
[[
"
$USER
NAME
"
!=
"
$DEFAULT_USER
"
||
-n
"
$SSH_CLIENT
"
]]
;
then
prompt_segment black default
"%(!.%{%F{yellow}%}.)%n@%m"
fi
}
...
...
themes/avit.zsh-theme
View file @
02d07f3e
...
...
@@ -17,7 +17,7 @@ function _user_host() {
local me
if [[ -n $SSH_CONNECTION ]]; then
me="%n@%m"
elif [[ $LOGNAME != $USER ]]; then
elif [[ $LOGNAME != $USER
NAME
]]; then
me="%n"
fi
if [[ -n $me ]]; then
...
...
themes/flazz.zsh-theme
View file @
02d07f3e
if [ "$USER" = "root" ]
if [ "$USER
NAME
" = "root" ]
then CARETCOLOR="red"
else CARETCOLOR="blue"
fi
...
...
themes/obraun.zsh-theme
View file @
02d07f3e
if [ "$USER" = "root" ]; then CARETCOLOR="red"; else CARETCOLOR="blue"; fi
if [ "$USER
NAME
" = "root" ]; then CARETCOLOR="red"; else CARETCOLOR="blue"; fi
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
...
...
themes/re5et.zsh-theme
View file @
02d07f3e
if [ "$USER" = "root" ]; then CARETCOLOR="red"; else CARETCOLOR="magenta"; fi
if [ "$USER
NAME
" = "root" ]; then CARETCOLOR="red"; else CARETCOLOR="magenta"; fi
local return_code="%(?..%{$fg_bold[red]%}:( %?%{$reset_color%})"
...
...
themes/sunrise.zsh-theme
View file @
02d07f3e
...
...
@@ -9,7 +9,7 @@ Y=$fg_no_bold[yellow]
B=$fg_no_bold[blue]
RESET=$reset_color
if [ "$USER" = "root" ]; then
if [ "$USER
NAME
" = "root" ]; then
PROMPTCOLOR="%{$R%}" PROMPTPREFIX="-!-";
else
PROMPTCOLOR="" PROMPTPREFIX="---";
...
...
tools/install.sh
View file @
02d07f3e
...
...
@@ -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
"^
$USER
NAME
:"
/etc/passwd |
awk
-F
:
'{print $7}'
>
~/.shell.pre-oh-my-zsh
fi
# Actually change the default shell to zsh
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment