caiogondim / bullet-train.zsh

:bullettrain_side: An oh-my-zsh shell theme based on the Powerline Vim plugin
MIT License
2.82k stars 383 forks source link

Adding DIR_TRUNCATE_REPO option #283

Closed JoshuaDoshua closed 5 years ago

JoshuaDoshua commented 6 years ago

Would love to have an option to truncate the cwd to the repo here (stolen option from the Spaceship theme, link below)

Desired behavior:

I've gotten it to work with just truncating to the current repo if inside a git repo, but my bash skills are minimal. I'd be happy to make a PR if anyone can help point me in the right direction or if I manage to get it working on my own.

Current code:

prompt_dir() {
  ...
  if $(git rev-parse --is-inside-work-tree >/dev/null >2&1); then
    local git_root=$(git rev-parse --show-toplevel)
    dir="$git_root:t${$(expr $pwd( -P) : "$git_root\(.*\)")}"
  elif [[ $BULLETTRAIN_DIR_EXTENDED == 0 ]]; then
  ...

<3 BULLETTRAIN, thanks!!

https://github.com/denysdovhan/spaceship-prompt/blob/master/sections/dir.zsh#L27 https://github.com/denysdovhan/spaceship-prompt/blob/master/lib/utils.zsh#L23