Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

zsh agnoster theme chagne prompt/ps1

Tags:

prompt

zsh

ps1

How can I change the prompt of my zsh shell while still retaining the cool coloring that agnoster provides? For people who don't know, it looks like this enter image description here I want to add some things like ! and \u before the working directories. I've tried the usual PS1="! \u \w" but it just gives this: enter image description here

EDIT: I found the right escaped characters for inserting information, but it cancels out the styling enter image description here How can I change the prompt while maintaining the styling?

like image 251
user1529956 Avatar asked Dec 12 '13 10:12

user1529956


People also ask

How do I change my theme on Agnoster?

Configure Agnoster theme For this, you first need to download a font that supports the unique characters and icons used by the theme. After installing the font, you can enable the Agnoster theme by changing the ZSH_THEME variable inside the ~/. zshrc configuration file.

How do I customize my oh my ZSH prompt?

To customize the ZSH prompt, we need to modify the prompt= variable inside the . zshrc file. We can populate the prompt variable with various placeholders, which will alter how the ZSH prompt appears.

How do I change my ZSH theme?

To change the Theme, simply change the ZSH_THEME value in ~/. zshrc file from robbyrussell to Avit. Run the following command to update the config. Open ITerm2 > Preferences > Profiles > Colors and change the background black color to use 20% gray as shown below.


1 Answers

You'd have to customise the theme, i.e. .oh-my-zsh/themes/agnoster.zsh-theme, add your own function to the build_prompt function and add whatever you need to the prompt:

## Main prompt
build_prompt() {
  RETVAL=$?
  prompt_status
  prompt_virtualenv
  prompt_context
  prompt_dir
  prompt_git
  prompt_hg
  prompt_end
}

I personally added a prompt_custom stub, which I then replace with the real prompt function in my .zshrc, so I only have to maintain that small customisation (probabaly worthty of a pull request at some stage...)

prompt_custom() {
}
like image 101
Danny Thomas Avatar answered Sep 17 '22 23:09

Danny Thomas