Skip to content

Instantly share code, notes, and snippets.

@itsthatguy
Last active August 11, 2017 17:35
Show Gist options
  • Select an option

  • Save itsthatguy/db2a8d6ebed178b66abef8a2e861a366 to your computer and use it in GitHub Desktop.

Select an option

Save itsthatguy/db2a8d6ebed178b66abef8a2e861a366 to your computer and use it in GitHub Desktop.

Revisions

  1. itsthatguy revised this gist Aug 11, 2017. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions prompt.sh
    Original file line number Diff line number Diff line change
    @@ -7,8 +7,7 @@ function git_dir_helper() {
    cd $git_dir_cdup > /dev/null
    echo ${PWD##*/}
    )"
    current_dir="$git_dir_top/$git_dir_path"
    current_dir=${current_dir%/}
    current_dir="$git_dir_top/${git_dir_path%/}"
    fi
    echo -n $current_dir
    }
  2. itsthatguy revised this gist Aug 11, 2017. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions prompt.sh
    Original file line number Diff line number Diff line change
    @@ -7,15 +7,15 @@ function git_dir_helper() {
    cd $git_dir_cdup > /dev/null
    echo ${PWD##*/}
    )"
    current_dir="$git_dir_top/${git_dir_path}"
    current_dir="$git_dir_top/$git_dir_path"
    current_dir=${current_dir%/}
    fi
    echo -n $current_dir
    }

    function bash_prompt_command() {
    current_dir=$(git_dir_helper)
    PS1="$git_dir_helper"
    PS1="$current_dir"
    }

    # Using with bash
  3. itsthatguy revised this gist Aug 11, 2017. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions prompt.sh
    Original file line number Diff line number Diff line change
    @@ -13,13 +13,13 @@ function git_dir_helper() {
    echo -n $current_dir
    }

    function my_prompt_command() {
    function bash_prompt_command() {
    current_dir=$(git_dir_helper)
    PS1="$git_dir_helper"
    }

    # Using with bash
    PROMPT_COMMAND=itg_dir
    PROMPT_COMMAND=bash_prompt_command

    # Using with zsh
    function precmd {
  4. itsthatguy created this gist Aug 11, 2017.
    27 changes: 27 additions & 0 deletions prompt.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    function git_dir_helper() {
    current_dir=${PWD##*/}
    if git rev-parse --git-dir > /dev/null 2>&1 && [ ! -d .git ]; then
    git_dir_cdup=$(git rev-parse --show-cdup)
    git_dir_path=$(git rev-parse --show-prefix)
    git_dir_top="$(
    cd $git_dir_cdup > /dev/null
    echo ${PWD##*/}
    )"
    current_dir="$git_dir_top/${git_dir_path}"
    current_dir=${current_dir%/}
    fi
    echo -n $current_dir
    }

    function my_prompt_command() {
    current_dir=$(git_dir_helper)
    PS1="$git_dir_helper"
    }

    # Using with bash
    PROMPT_COMMAND=itg_dir

    # Using with zsh
    function precmd {
    PROMPT="$(itg_dir)"
    }