Skip to content

Instantly share code, notes, and snippets.

@thumbnail
Last active August 22, 2020 08:34
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thumbnail/6d5566803ddf2bf5a065e85d49717f88 to your computer and use it in GitHub Desktop.
Save thumbnail/6d5566803ddf2bf5a065e85d49717f88 to your computer and use it in GitHub Desktop.
leiningen current verion prompt
function lein_current_version() {
command grep defproject project.clj 2> /dev/null | grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn} -o "\".*"\" | sed "s/\"//g"
}
function lein_prompt() {
cat project.clj &> /dev/null || return 0
ZSH_THEME_LEIN_PROMPT_PREFIX="%{$fg_bold[green]%}"
ZSH_THEME_LEIN_PROMPT_SUFFIX="%{$reset_color%} "
echo "$ZSH_THEME_LEIN_PROMPT_PREFIX$(lein_current_version)$ZSH_THEME_LEIN_PROMPT_SUFFIX"
}
@thumbnail
Copy link
Author

thumbnail commented Jun 1, 2020

Adds lein-version of current project to the lein prompt:
image

Enable by appending $(lein_prompt) to your current theme's $ZSH_PROMPT (located at ~/.oh-my-zsh/themes/$ZSH_THEME.zsh-theme).

E.g. like for robbyrussel:

local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )"
PROMPT='${ret_status} %{$fg[cyan]%}%c%{$reset_color%} $(lein_prompt)$(git_prompt_info)'

ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"

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