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:

introduzca la descripción de la imagen aquí

introduzca la descripción de la imagen aquí

¿Alguien sabe lo que está pasando? Incluso intenté DEFAULT_USER="$USER@$HOST" sin suerte.

Si vuelvo al tema por defecto, Robby Russell, funciona bien.

introduzca la descripción de la imagen aquí

Author: Drew, 2015-02-13

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 () { }
 54
Author: hchbaw,
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.

  1. Paso 1. abra su archivo .zshrc por vim .zshrc

  2. Paso 2. vaya al final de su archivo.

  3. 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:)

 33
Author: hqt,
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:

introduzca la descripción de la imagen aquí

 18
Author: Rizqi N. Assyaufi,
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].

 10
Author: Munshi Wahid,
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.

 2
Author: IAmKale,
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.

 1
Author: David Pan,
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.

 0
Author: William Leiby,
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.

 0
Author: John Zhow,
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