Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
zsh config
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
# ZSH_THEME="robbyrussell"
ZSH_THEME="agnoster"
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
# Set to this to use case-sensitive completion
# CASE_SENSITIVE="true"
# Comment this out to disable weekly auto-update checks
# DISABLE_AUTO_UPDATE="true"
# Uncomment following line if you want to disable colors in ls
# DISABLE_LS_COLORS="true"
# Uncomment following line if you want to disable autosetting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment following line if you want red dots to be displayed while waiting for completion
# COMPLETION_WAITING_DOTS="true"
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
plugins=(git)
alias st='/usr/bin/sublime-text'
source $ZSH/oh-my-zsh.sh
# Customize to your needs...
export PATH=/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
# optionally set DEFAULT_USER in ~/.zshrc to your regular username to hide the “user@hostname” info when you’re logged in as yourself on your local machine.
DEFAULT_USER=tangkai@virtual-machine
@mhriemers
Copy link

mhriemers commented May 7, 2013

Just enter your username, leave out the machine.

@ujjwalt
Copy link

ujjwalt commented Jun 26, 2013

Still doesn't work

@machineboy2045
Copy link

machineboy2045 commented Oct 24, 2013

I had trouble too. Finally got it to work DEFAULT_USERNAME=username
My mistake was I put spaces around the '='. Don't include the machine and don't use quotes around the username

@zo0o0ot
Copy link

zo0o0ot commented Dec 6, 2013

DEFAULT_USER=whoami

There are backticks around the command whoami.

ohmyzsh/ohmyzsh#2033

@dnlR
Copy link

dnlR commented Mar 26, 2014

For me worked with export DEFAULT_USER="username". Its worth mentioning that this didn't work for me with other themes, like pygmalion for example.

@manderly
Copy link

manderly commented Aug 8, 2014

Just got it working - this shows no username/computer name in the Terminal at all. Using iTerm2 and zsh.

export DEFAULT_USER='whoami'

(Use ` backticks around whoami)

@ccharlton
Copy link

ccharlton commented Aug 12, 2015

Adding export DEFAULT_USER=whoami`` in ~/.zshrc did the trick for me.

@a17levine
Copy link

a17levine commented Sep 1, 2015

ugh none of these worked for me, did it just like @ccharlton with export DEFAULT_USER=whoami``

@maazghani
Copy link

maazghani commented Sep 15, 2015

The agnoster.theme has this section

# Context: user@hostname (who am I and where am I)
prompt_context() {
  if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
    prompt_segment black default "%(!.%{%F{yellow}%}.)$USER@%m"
  fi
}

So you need to export USER=whoami`` in the ~/.zshrc.

@bmoo0
Copy link

bmoo0 commented Nov 10, 2015

Still no luck for me $DEFAULT_USER="username" hides everything from the prompt I still want to display the username

@briggleman
Copy link

briggleman commented Dec 1, 2015

@himynameisbeni modify the following in the agnoster.zsh-theme file:

# Context: user@hostname (who am I and where am I)
prompt_context() {
  if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
    prompt_segment black default "%(!.%{%F{yellow}%}.)$USER@%m"
  fi
}

to:

# Context: user@hostname (who am I and where am I)
prompt_context() {
  if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
    prompt_segment black default "%(!.%{%F{yellow}%}.)$USER"
  fi
}

dropping the @%m machine name.

@rastalamm
Copy link

rastalamm commented Mar 1, 2016

This doesn't work on the pygmalion theme. Does anyone have a work around?

@NitroCao
Copy link

NitroCao commented Apr 24, 2016

gedit ~/.oh-my-zsh/themes/agnoster.zsh-theme
Find these:

Context: user@hostname (who am I and where am I)

prompt_context() {
if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
prompt_segment black default "%(!.%{%F{yellow}%}.)$USER@%m"
fi
}
If you want to let her display anything, you should drop the '$USER@%m', also you can use any words to change them.

@panigrc
Copy link

panigrc commented Jun 21, 2016

@ubuntu 14.04 DEFAULT_USER=myusername worked just fine

@alquesadilla
Copy link

alquesadilla commented Jun 25, 2016

@ubuntu 14.04 DEFAULT_USER=myusername worked just fine also

@ChrisBtt
Copy link

ChrisBtt commented Jul 30, 2016

I tried a bit and at the end it shows: DEFAULT_USER is case-sensitive

@mhalano
Copy link

mhalano commented Sep 17, 2016

Just 'adben' and 'agnoster' themes support this feature.

@ericschmar
Copy link

ericschmar commented Sep 20, 2016

Using Mac OS X with iTerm2 and zsh with the agnoster theme, simply using:
export USER=ARBITRARYNAMEHERE
where the arbitrary name is surrounded by back ticks.

@mayangithub
Copy link

mayangithub commented Sep 23, 2016

I'm using Mac OS X with iTerm2 and ohmyzsh with agnoster theme

USER=``

works for me to hide the username@hostname

@mcornella
Copy link

mcornella commented Oct 28, 2016

Please don't use that workaround (USER=""), it could mess up certain commands or functions. Better use either of these:

DEFAULT_USER=$USER

# or

prompt_context() {}

agnoster wiki section.

@HendrixString
Copy link

HendrixString commented Mar 22, 2017

try

DEFAULT_USER=`whoami`

@keir-rex
Copy link

keir-rex commented Sep 21, 2018

Regarding these two comments:
@dnlR

For me worked with export DEFAULT_USER="username". Its worth mentioning that this didn't work for me with other themes, like pygmalion for example.

@rastalamm

This doesn't work on the pygmalion theme. Does anyone have a work around?

I had the same problem and found the below works:

  # Context: user@hostname (who am I and where am I)
  prompt_context() {
    if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
      base_prompt='%{$fg[magenta]%}%n%{$reset_color%}%{$fg[cyan]%}@%{$reset_color%}%{$fg[yellow]%}%m%{$reset_color%}%{$fg[red]%}:%{$reset_color%}%{$fg[cyan]%}%0~%{$reset_color%}%{$fg[red]%}|%{$reset_color%}'
    fi
  }
  base_prompt='%{$fg[cyan]%}%0~%{$reset_color%}%{$fg[red]%}|%{$reset_color%}'

Drop the above snippet in place of the line below in ~/.oh-my-zsh/themes/pygmalion.zsh-theme:

base_prompt='%{$fg[magenta]%}%n%{$reset_color%}%{$fg[cyan]%}@%{$reset_color%}%{$fg[yellow]%}%m%{$reset_color%}%{$fg[red]%}:%{$reset_color%}%{$fg[cyan]%}%0~%{$reset_color%}%{$fg[red]%}|%{$reset_color%}'

The docs for prompt expansion in zsh as per ohmyzsh/ohmyzsh#5904: http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html

@twchengyang
Copy link

twchengyang commented Jan 29, 2019

try

DEFAULT_USER=`whoami`

It works for me. Thanks @shutterfly

@Kaiser925
Copy link

Kaiser925 commented Mar 3, 2019

try

DEFAULT_USER=`whoami`

Thanks. It works

@maddiewen
Copy link

maddiewen commented Jun 29, 2019

ah that's not working for me either (iTerm2 + agnoster)

@SGarcia710
Copy link

SGarcia710 commented Apr 13, 2020

Please don't use that workaround (USER=""), it could mess up certain commands or functions. Better use either of these:

DEFAULT_USER=$USER

# or

prompt_context() {}

agnoster wiki section.

Thanks! This worked for me. iterm2 + agnoster

@kitofr
Copy link

kitofr commented Jun 26, 2020

According to the Readme you can just remove segments with

export AGNOSTER_PROMPT_SEGMENTS[X]=

I used export AGNOSTER_PROMPT_SEGMENTS[2]= to remove the user

@sud007
Copy link

sud007 commented Jul 19, 2021

@himynameisbeni modify the following in the agnoster.zsh-theme file:

# Context: user@hostname (who am I and where am I)
prompt_context() {
  if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
    prompt_segment black default "%(!.%{%F{yellow}%}.)$USER@%m"
  fi
}

to:

# Context: user@hostname (who am I and where am I)
prompt_context() {
  if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
    prompt_segment black default "%(!.%{%F{yellow}%}.)$USER"
  fi
}

dropping the @%m machine name.

Worked fine for agnoster. I just needed my machine name hence removed $n@ (actually it was not @user). It worked!

@Charles-Wang-WooliesX
Copy link

Charles-Wang-WooliesX commented May 23, 2022

try

DEFAULT_USER=`whoami`

Thanks it worked for me.

@ramakay
Copy link

ramakay commented Aug 18, 2022

This worked

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment