Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

agnoster theme - only show ~ as working directory #5479

Closed
quang-ha opened this issue Sep 30, 2016 · 14 comments
Closed

agnoster theme - only show ~ as working directory #5479

quang-ha opened this issue Sep 30, 2016 · 14 comments
Labels
Area: theme Issue or PR related to a theme Support Request for support

Comments

@quang-ha
Copy link

Is there a way to only show ~ instead of the full directory in the agnoster theme? I kind of love the blue rectangle strip but again don't want to show the full working path.

@brianjking
Copy link

@quang-ha I'm not sure about the Agnoster theme, however, you definitely can in Powerlevel9k.

@mcornella
Copy link
Member

You can redefine the prompt_dir function like so:

prompt_dir () {
    prompt_segment blue black '~'
}

Paste that at the end of your zshrc file and you should be good to go.

@betogrun
Copy link

betogrun commented May 3, 2017

@quang-ha you can also show only the current folder without the full path:

prompt_dir() {
  prompt_segment blue black "${PWD##*/}"
}

@hck94829
Copy link

hck94829 commented Jun 8, 2017

@betogrun r u sure? What I am getting is this
${PWD##*/} showing on the screen

@betogrun
Copy link

betogrun commented Jun 8, 2017

@hck94829 I'm not sure why it is no longer working.
I've customized this theme locally and now I'm using an alternative approach:

prompt_dir() {
  prompt_segment blue $PRIMARY_FG " `basename ${PWD/#$HOME/'~'}` "
}

More info: betogrun/agnoster-zsh-theme@3c57a1d

@timolinn
Copy link

timolinn commented Jul 5, 2017

@hck94829 Make sure you put in double quotes like this "${PWD##*/}"

@fepegar
Copy link

fepegar commented Aug 28, 2017

I do just:

prompt_dir() {
  prompt_segment blue black '%c'
}

@jorgealegre
Copy link

jorgealegre commented Oct 19, 2017

Technically '%c' is deprecated. Documentation recommends '%.' or '%1/'.

@RenuxRenardi94
Copy link

What @georgealegre says, I tried '%.' and it does just that. Instead of the full path, it shows the current directory. Which I'd say it's good, because sometimes the full path would be so wide that there's almost no space left for commands...

@TerminatorP
Copy link

for me '%' or '~1' didn't work but as @fepegar said '%c' worked...

@RenuxRenardi94
Copy link

Actually, I got that problem too, first. It's kind of embarrassing to say it, but I got the characters wrong. '%' and '~1' do nothing. It's '%.' and '~1/'. The dot and the slash, kind of easy not to see them.

@aaophilip
Copy link

Here's what worked for me:

prompt_dir() {
    prompt_segment blue black "`basename ${PWD##*/}`"
} 

@SarKurd
Copy link

SarKurd commented Sep 4, 2018

@betogrun comment works for me but how to show parent too? i want to show parent and current directory

@mcornella
Copy link
Member

@SarKurd you can do

prompt_dir() {
  prompt_segment blue black '%2/'
}

You can see more prompt expansion characters in the documentation.

@ohmyzsh ohmyzsh locked as resolved and limited conversation to collaborators Sep 4, 2018
@mcornella mcornella added Support Request for support and removed Type: question labels Mar 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Area: theme Issue or PR related to a theme Support Request for support
Projects
None yet
Development

No branches or pull requests