From da0ff1a44c957731d443597f8eb89449df375cc5 Mon Sep 17 00:00:00 2001 From: Tim Heckman Date: Mon, 14 Nov 2016 00:00:13 -0800 Subject: [PATCH] [agnoster] add a short path option for the theme This change to the `agnoster` theme adds an option for using the name of the current directory instead of a relative path. Assume you're in the following directory: `~/.oh-my-zsh/custom/themes`. If you set `AGNOSTER_SHORT_PATH=1` in your `.zshrc` file, the path will render only as `themes` on the command line instead of `~/.oh-my-zsh/custom/themes`. In the implementation of this option, another was added to give you even more control if you want it (`AGNOSTER_CURRENT_PATH`). If `AGNOSTER_SHORT_PATH` is unset and `AGNOSTER_CURRENT_PATH` is set, that value will be used for the path value on the prompt. --- themes/agnoster.zsh-theme | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index 103041ee..42c88b89 100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -164,7 +164,11 @@ prompt_hg() { # Dir: current working directory prompt_dir() { - prompt_segment blue black '%~' + # if AGNOSTER_SHORT_PATH is set use %1~ for the path value + # that will turn '~/.oh-my-zsh/custom/themes' in to 'themes' + [ -n "${AGNOSTER_SHORT_PATH}" ] && AGNOSTER_CURRENT_PATH='%1~' + + prompt_segment blue black "${AGNOSTER_CURRENT_PATH:=%~}" } # Virtualenv: current working virtualenv