ZSH Agnoster Theme mostrando el nombre de la máquina
Tengo un servidor de desarrollo alojado en Digital Ocean, usando Ubuntu 14.04. Cambié mi shell a ZSH y decidí ir con el tema Agnoster . Para que user@hostname
deje de mostrarse, establezco el DEFAULT_USER
en mi .archivo zshrc.
Por alguna razón en el servidor ubuntu, eso no está funcionando. El nombre de host todavía se muestra, y no desaparecerá. Estoy haciendo exactamente lo mismo en mi Mac OSX, y funciona bien.
Aquí están algunos capturas de pantalla:
¿Alguien sabe lo que está pasando? Incluso intenté DEFAULT_USER="$USER@$HOST"
sin suerte.
Si vuelvo al tema por defecto, Robby Russell, funciona bien.
8 answers
Es la característica según este; cuando estamos ssh
ing, se mostrará el nombre de host.
Sobreescribiendo la función prompt_context
o build_prompt
en el tema Agnoster rescatará. Por ejemplo, poniendo los siguientes fragmentos de código al final de ~/.zshrc
.
# redefine prompt_context for hiding user@hostname
prompt_context () { }
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-02-13 04:13:05
Aquí está mi versión de las dos primeras respuestas. Lo explican muy claramente. Me fusionaré de nuevo.
Paso 1. abra su archivo
.zshrc
porvim .zshrc
Paso 2. vaya al final de su archivo.
-
Pegue este código:
cuidado con sangrar de nuevo su código
prompt_context() {
if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
prompt_segment black default "%(!.%{%F{yellow}%}.)$USER"
fi
}
Enlace de referencia: código de tema de agnoster
Espero que esto ayude:)
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-11-30 02:31:54
También estoy usando el tema agnoster.
Editar agnoster.zsh-theme
y buscar $user@%m
y eliminar @%m
.
Muestra de imagen:
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-05-04 14:36:58
Puede configurar DEFAULT_USER="[user name]"
en su archivo .zshrc
y dejará de mostrar el user@hostname
en su terminal.
Para obtener el [user name]
, escriba id -un
en su terminal y mostrará el valor [user name]
.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-02-28 14:19:37
Si está en macOS , la adición de una sola línea a su archivo ~/.zshrc
es suficiente para ocultar el nombre de la máquina en el Terminal:
# Where we specify the theme
ZSH_THEME="agnoster"
# Force yourself as the system's default user
DEFAULT_USER="$(whoami)"
Esto negará la verificación "$user" != "$DEFAULT_USER"
aquí, ocultando así el nombre de la máquina localmente mientras se muestra para las conexiones SSH.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-05-24 19:23:43
1.
abrir ~/.zshrc
añadir línea:
DEFAULT_USER = whoami
o exportar DEFAULT_USER = myusername (mac os x)
2. abrir ~/.oh-my-zsh / themes / agnoster.zsh-archivos de tema.
Buscar # # Mensaje principal añadir # para la línea prompt_context.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-09-06 13:59:19
Pon esto en tu .archivo zshrc antes del 'source source ZSH/oh-my-zsh.sh"
DEFAULT_USER=drewr
También uso Agnoster, y esto es lo que puse para quitar el nombre de usuario de la visualización.
Espero que esto ayude.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-07-03 14:10:54
No necesitamos editar agnoster.zsh-theme
pero añadimos el siguiente código al final de .zshrc
:
export USER=''
prompt_context() {
if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
prompt_segment black default "%(!.%{%F{yellow}%}.)$USER"
fi
}
Podemos cambiar export USER=''
como export USER='john'
para mostrar lo que queremos.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-08-06 12:27:08