Open elbrinke opened 7 years ago
Open your .zshrc
and paste this at the bottom:
prompt_context() {
if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
prompt_segment black default "%(!.%{%F{yellow}%}.)$USER"
fi
}
This makes only your username to appear. If you don't want that too, just comment out this line prompt_segment black default "%(!.%{%F{yellow}%}.)$USER"
This PR will help: https://github.com/agnoster/agnoster-zsh-theme/pull/40
May I ask why the DEFAULT_USER
query is there at all?
Perhaps I miss something, but it seems like a double-check, when SSH_CLIENT
is already being queried. It's an extra step required when working on different machines with different users, or when sharing or adapting dotfiles. It potentially also leads to disclosure of people's local usernames in their public dotfiles.
How to set agnoster theme in termux please tell me
In my .zshrc I did:
# change prompt
prompt_context() {
prompt_segment $PRIMARY_FG default " 🌈 "
}
prompt_dir() {
prompt_segment blue $PRIMARY_FG ' %c '
}
:)
My config in ~/.oh-my-zsh/themes/agnoster.zsh-theme
to random emoji.
prompt_context() {
# Custom (Random emoji)
emojis=("⚡️" "🔥" "💀" "👑" "😎" "🐸" "🐵" "🦄" "🌈" "🍻" "🚀" "💡" "🎉" "🔑" "🇹🇭" "🚦" "🌙")
RAND_EMOJI_N=$(( $RANDOM % ${#emojis[@]} + 1))
prompt_segment black default "${emojis[$RAND_EMOJI_N]} "
}
@itsmehemant123 ty so much
In my .zshrc I did:
# change prompt prompt_context() { prompt_segment $PRIMARY_FG default " 🌈 " } prompt_dir() { prompt_segment blue $PRIMARY_FG ' %c ' }
:)
thanks for that!
May I ask why the DEFAULT_USER query is there at all?
I think this is in case you're su
-ing or logging in as an unusual user on your local machine, or you have a typical "regular" account you use on multiple machines.
Similar to @kud, but modified my prompt to work in agnoster.
I updated the prompt_context
in ~/.oh-my-zsh/themes/agnoster.zsh-theme
(because it was being overwritten) and used the agnoster background variable (CURRENT_BG
):
prompt_context() {
prompt_segment $CURRENT_BG default " 🌈 "
}
Simply add DEFAULT_USER=$USER
in .zshrc
@itsmehemant123 's solution didn't quite work for me.
I want to recommend changing this in your theme, rather than your .zshrc
like @TheLandoCal , I updated the prompt_context
in ~/.oh-my-zsh/themes/agnoster.zsh-theme
.
For me, I just wanted to show my username, without my '@ hostname'.
Original agnoster.zsh-theme
:
prompt_context() {
if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
prompt_segment black default "%(!.%{%F{yellow}%}.)%n@%m"
fi
}
I just removed @%m
from line 92.
Updated agnoster.zsh-theme
:
prompt_context() {
if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
prompt_segment black default "%(!.%{%F{yellow}%}.)%n"
fi
}
wow, nothing helped. I'm using bira
theme.
Iam using oh my zsh and ur theme is listed there how can I install ur theme, pls tell me
On MacOS 10.15 Catalina in 2021 year
Open the file /private/etc/zshrc in a text editor
Locate the comment: # Default prompt
Modify the line that looks like this: PS1="%n@%m~ %& # "
Save the file. You will be prompted to enter a password to save it.
Load a new Terminal window.
For example, you can:
Remove "%n@%m" to get rid of both the username and computer name
Remove "%n" to get rid of the user name
Remove "%m" to get rid of the machine name
How to hide the owner and group names when doing listings (ls -la) for instance?
Make sure you add this line to the ~/.zshrc
file:
export DEFAULT_USER="$(whoami)"
Thanks! The last thing would be how to hide or change the user name on the top of the Terminal window?
Thanks! The last thing would be how to hide or change the user name on the top of the Terminal window?
In order to achieve what you want, in the ~/.zshrc
file:
First uncomment DISABLE_AUTO_TITLE="true"
and after
add this line precmd () { print -Pn "\e]2; %~\a" } # title bar prompt
at the end of the file:
Source https://superuser.com/questions/79972/set-the-title-of-the-terminal-window-to-the-current-directory
In ~/.oh-my-zsh/themes/agnoster.zsh-theme
change the prompt_context
function to not do anything. Like this:
prompt_context() {}
My config in
~/.oh-my-zsh/themes/agnoster.zsh-theme
to random emoji.prompt_context() { # Custom (Random emoji) emojis=("⚡️" "🔥" "💀" "👑" "😎" "🐸" "🐵" "🦄" "🌈" "🍻" "🚀" "💡" "🎉" "🔑" "🇹🇭" "🚦" "🌙") RAND_EMOJI_N=$(( $RANDOM % ${#emojis[@]} + 1)) prompt_segment black default "${emojis[$RAND_EMOJI_N]} " }
woooo tankyou bro
It is said to do the following: Optionally set DEFAULT_USER to your regular username followed by prompt_context(){} in ~/.zshrc to hide the “user@hostname” info when you’re logged in as yourself on your local machine.
What does that look like?