Skip to content

Instantly share code, notes, and snippets.

@ByScripts
Last active October 9, 2015 07:37
Show Gist options
  • Select an option

  • Save ByScripts/3462873 to your computer and use it in GitHub Desktop.

Select an option

Save ByScripts/3462873 to your computer and use it in GitHub Desktop.

Revisions

  1. ByScripts revised this gist Nov 7, 2013. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions .bash_prompt
    Original file line number Diff line number Diff line change
    @@ -11,6 +11,7 @@ WorkingDirColor="\e[0;93m"
    TimeColor="\e[0;96m"
    RvmColor=$WorkingDirColor
    RvmGemsetColor=$GitOkColor
    HostnameColor=$GitOkColor

    # Get the current working dir "home-shortened" (~/dir instead of /home/user/dir)
    function getShortWorkingDirectory {
    @@ -57,6 +58,7 @@ function gitPrompt {
    branch=$(getGitBranch)
    status=$(getGitStatus)
    time=$(date +%H:%M:%S)
    hostname=$(hostname)
    before="───┤ "
    after=" ├───"
    if [[ $(type -t rvm-prompt) != "" ]]; then
    @@ -69,8 +71,8 @@ function gitPrompt {
    LineColor=$RootLineColor
    fi

    prompt="┌$before$time$after"
    colored_prompt="$LineColor┌$before$TimeColor$time$LineColor$after"
    prompt="┌$before$hostname$after$before$time$after"
    colored_prompt="$LineColor┌$before$HostnameColor$hostname$LineColor$after$before$TimeColor$time$LineColor$after"

    if [[ $status != "nogit" ]]; then

  2. ByScripts revised this gist Nov 4, 2013. 1 changed file with 19 additions and 6 deletions.
    25 changes: 19 additions & 6 deletions .bash_prompt
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    # To use, download this file at the root of your home directory, than add :
    # . .bash_git.sh
    # . .bash_prompt
    # at the end of you .bashrc file

    # Colors
    @@ -19,6 +19,15 @@ function getShortWorkingDirectory {
    echo $short_working_directory
    }

    if [[ $(type -t __git_ps1) == "" ]]; then
    function __git_ps1 {
    local b="$(git symbolic-ref HEAD 2>/dev/null)";
    if [ -n "$b" ]; then
    printf " (%s)" "${b##refs/heads/}";
    fi
    }
    fi

    # Get the current Git branch without parenthesis
    function getGitBranch {
    echo $(__git_ps1 "%s")
    @@ -50,8 +59,10 @@ function gitPrompt {
    time=$(date +%H:%M:%S)
    before="───┤ "
    after=" ├───"
    rvm=$(rvm-prompt v)
    rvm_gemset=$(rvm-prompt g)
    if [[ $(type -t rvm-prompt) != "" ]]; then
    rvm=$(rvm-prompt v)
    rvm_gemset=$(rvm-prompt g)
    fi

    # Change the line color if logged as root (sudo)
    if [[ $(whoami) == "root" ]]; then
    @@ -87,8 +98,10 @@ function gitPrompt {
    prompt="$prompt$before$dir$after"
    colored_prompt="$colored_prompt$before$WorkingDirColor$dir$LineColor$after"

    prompt="$prompt$before$rvm$rvm_gemset$after"
    colored_prompt="$colored_prompt$before$RvmColor$rvm$RvmGemsetColor$rvm_gemset$LineColor$after"
    if [[ $rvm != "" ]]; then
    prompt="$prompt$before$rvm$rvm_gemset$after"
    colored_prompt="$colored_prompt$before$RvmColor$rvm$RvmGemsetColor$rvm_gemset$LineColor$after"
    fi

    # Counting the length of the generated prompt
    length=$(echo $prompt | wc -m)
    @@ -109,4 +122,4 @@ function gitPrompt {
    }

    # Replace the current prompt
    export PS1="\$(gitPrompt)"
    export PS1="\$(gitPrompt)"
  3. ByScripts renamed this gist Jan 29, 2013. 1 changed file with 9 additions and 3 deletions.
    12 changes: 9 additions & 3 deletions .bash_git.sh → .bash_prompt
    Original file line number Diff line number Diff line change
    @@ -5,10 +5,12 @@
    # Colors
    LineColor="\e[0;36m"
    GitNotOkColor="\e[1;31m"
    GitOkColor="\e[1;32m"
    GitOkColor="\e[0;32m"
    RootLineColor=$GitNotOkColor
    WorkingDirColor="\e[0;93m"
    TimeColor="\e[0;96m"
    RvmColor=$WorkingDirColor
    RvmGemsetColor=$GitOkColor

    # Get the current working dir "home-shortened" (~/dir instead of /home/user/dir)
    function getShortWorkingDirectory {
    @@ -48,6 +50,8 @@ function gitPrompt {
    time=$(date +%H:%M:%S)
    before="───┤ "
    after=" ├───"
    rvm=$(rvm-prompt v)
    rvm_gemset=$(rvm-prompt g)

    # Change the line color if logged as root (sudo)
    if [[ $(whoami) == "root" ]]; then
    @@ -63,7 +67,7 @@ function gitPrompt {

    prompt="$prompt$before"
    colored_prompt="$colored_prompt$before"

    if [[ $status == "ok" ]]; then

    # The current branch is clean
    @@ -83,12 +87,14 @@ function gitPrompt {
    prompt="$prompt$before$dir$after"
    colored_prompt="$colored_prompt$before$WorkingDirColor$dir$LineColor$after"

    prompt="$prompt$before$rvm$rvm_gemset$after"
    colored_prompt="$colored_prompt$before$RvmColor$rvm$RvmGemsetColor$rvm_gemset$LineColor$after"

    # Counting the length of the generated prompt
    length=$(echo $prompt | wc -m)

    # Compute the length difference between total columns, and prompt length
    let fill_count=$COLUMNS-$length

    # Right pad the prompt to fill the screen width
    while [[ $fill_count -gt 0 ]]; do
    prompt="$prompt─"
  4. Thierry Goettelmann revised this gist Sep 1, 2012. 1 changed file with 25 additions and 0 deletions.
    25 changes: 25 additions & 0 deletions byscripts.zsh-theme
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    fillme(){
    wdir_length=${#${PWD/#$HOME/"~"}}
    gpi=$(git_prompt_info_reverse)
    local zero='%([BSUbfksu]|([FB]|){*})'
    local gpi_length=${#${(S%%)gpi//$~zero/}}

    let length=$COLUMNS-$wdir_length-$gpi_length-32

    local fill=""
    while [[ $length -gt 0 ]]; do
    fill="$fill"
    let length=$length-1
    done
    echo $fill
    }

    PROMPT=$'\
    %{$fg[cyan]%}┌───┤%{$fg[white]%} %D{%H:%M:%S} %{$fg[cyan]%}├──────┤ %{$fg[yellow]%}%~%{$fg[cyan]%} ├───$(git_prompt_info_reverse)───$(fillme)\
    └──▶ %{$reset_color%} '
    PROMPT2=" %{$fg[cyan]%}┈▶%{$reset_color%} "

    ZSH_THEME_GIT_PROMPT_PREFIX="───┤ "
    ZSH_THEME_GIT_PROMPT_SUFFIX="%{$fg_no_bold[cyan]%} ├───"
    ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg_bold[red]%}✕ "
    ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[green]%}✓ "
  5. ByScripts revised this gist Aug 25, 2012. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion .bash_git.sh
    Original file line number Diff line number Diff line change
    @@ -6,6 +6,7 @@
    LineColor="\e[0;36m"
    GitNotOkColor="\e[1;31m"
    GitOkColor="\e[1;32m"
    RootLineColor=$GitNotOkColor
    WorkingDirColor="\e[0;93m"
    TimeColor="\e[0;96m"

    @@ -48,6 +49,11 @@ function gitPrompt {
    before="───┤ "
    after=" ├───"

    # Change the line color if logged as root (sudo)
    if [[ $(whoami) == "root" ]]; then
    LineColor=$RootLineColor
    fi

    prompt="$before$time$after"
    colored_prompt="$LineColor$before$TimeColor$time$LineColor$after"

    @@ -93,7 +99,7 @@ function gitPrompt {
    # Insert a new line before the prompt, for more clarity
    echo ""
    echo -e $colored_prompt
    echo -ne "└─▶ "
    echo -ne "└─"
    }

    # Replace the current prompt
  6. ByScripts revised this gist Aug 25, 2012. 1 changed file with 24 additions and 0 deletions.
    24 changes: 24 additions & 0 deletions .bash_git.sh
    Original file line number Diff line number Diff line change
    @@ -2,22 +2,29 @@
    # . .bash_git.sh
    # at the end of you .bashrc file

    # Colors
    LineColor="\e[0;36m"
    GitNotOkColor="\e[1;31m"
    GitOkColor="\e[1;32m"
    WorkingDirColor="\e[0;93m"
    TimeColor="\e[0;96m"

    # Get the current working dir "home-shortened" (~/dir instead of /home/user/dir)
    function getShortWorkingDirectory {
    escaped_home=$(echo $HOME | sed -e 's/[\/&]/\\&/g')
    short_working_directory=$(pwd | sed -e "s/$escaped_home/~/g")
    echo $short_working_directory
    }

    # Get the current Git branch without parenthesis
    function getGitBranch {
    echo $(__git_ps1 "%s")
    }

    # Get the current Git status
    # ok = Current Git branch is clean
    # nok = Current Git branch is dirty
    # notgit = Not in a git repository
    function getGitStatus {

    if [[ $(getGitBranch) != "" ]]; then
    @@ -32,6 +39,7 @@ function getGitStatus {
    fi
    }

    # Build the prompt
    function gitPrompt {
    dir=$(getShortWorkingDirectory)
    branch=$(getGitBranch)
    @@ -44,12 +52,21 @@ function gitPrompt {
    colored_prompt="$LineColor$before$TimeColor$time$LineColor$after"

    if [[ $status != "nogit" ]]; then

    # We are in a git repository

    prompt="$prompt$before"
    colored_prompt="$colored_prompt$before"

    if [[ $status == "ok" ]]; then

    # The current branch is clean

    prompt="$prompt$branch"
    colored_prompt="$colored_prompt $GitOkColor$branch"
    else

    # The current branch is dirty
    prompt="$prompt$branch"
    colored_prompt="$colored_prompt $GitNotOkColor$branch"
    fi
    @@ -60,17 +77,24 @@ function gitPrompt {
    prompt="$prompt$before$dir$after"
    colored_prompt="$colored_prompt$before$WorkingDirColor$dir$LineColor$after"

    # Counting the length of the generated prompt
    length=$(echo $prompt | wc -m)

    # Compute the length difference between total columns, and prompt length
    let fill_count=$COLUMNS-$length

    # Right pad the prompt to fill the screen width
    while [[ $fill_count -gt 0 ]]; do
    prompt="$prompt"
    colored_prompt="$colored_prompt"
    let fill_count=$fill_count-1
    done

    # Insert a new line before the prompt, for more clarity
    echo ""
    echo -e $colored_prompt
    echo -ne "└─▶ "
    }

    # Replace the current prompt
    export PS1="\$(gitPrompt)"
  7. ByScripts revised this gist Aug 25, 2012. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion .bash_git.sh
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # To use, download this file at the root of your home directory, then add :
    # To use, download this file at the root of your home directory, than add :
    # . .bash_git.sh
    # at the end of you .bashrc file

    @@ -68,6 +68,7 @@ function gitPrompt {
    colored_prompt="$colored_prompt"
    let fill_count=$fill_count-1
    done
    echo ""
    echo -e $colored_prompt
    echo -ne "└─▶ "
    }
  8. ByScripts revised this gist Aug 25, 2012. 1 changed file with 11 additions and 13 deletions.
    24 changes: 11 additions & 13 deletions .bash_git.sh
    Original file line number Diff line number Diff line change
    @@ -1,14 +1,12 @@
    # To use, download this file at the root of your home directory, than add :
    # To use, download this file at the root of your home directory, then add :
    # . .bash_git.sh
    # at the end of you .bashrc file

    Color_Off="\e[0m" # Text Reset
    Cyan="\e[0;36m" # Cyan
    Red="\e[1;31m" # Bold Red
    Green="\e[1;32m" # Bold Green
    Yellow="\e[0;93m" # Yellow
    Blue="\e[0;94m" # Blue
    ICyan="\e[0;96m" # Intense Cyan
    LineColor="\e[0;36m"
    GitNotOkColor="\e[1;31m"
    GitOkColor="\e[1;32m"
    WorkingDirColor="\e[0;93m"
    TimeColor="\e[0;96m"

    function getShortWorkingDirectory {
    escaped_home=$(echo $HOME | sed -e 's/[\/&]/\\&/g')
    @@ -43,24 +41,24 @@ function gitPrompt {
    after=" ├───"

    prompt="$before$time$after"
    colored_prompt="$Cyan$before$ICyan$time$Cyan$after"
    colored_prompt="$LineColor$before$TimeColor$time$LineColor$after"

    if [[ $status != "nogit" ]]; then
    prompt="$prompt$before"
    colored_prompt="$colored_prompt$before"
    if [[ $status == "ok" ]]; then
    prompt="$prompt$branch"
    colored_prompt="$colored_prompt $Green$branch"
    colored_prompt="$colored_prompt $GitOkColor$branch"
    else
    prompt="$prompt$branch"
    colored_prompt="$colored_prompt $Red$branch"
    colored_prompt="$colored_prompt $GitNotOkColor$branch"
    fi
    prompt="$prompt$after"
    colored_prompt="$colored_prompt$Cyan$after"
    colored_prompt="$colored_prompt$LineColor$after"
    fi

    prompt="$prompt$before$dir$after"
    colored_prompt="$colored_prompt$before$Yellow$dir$Cyan$after"
    colored_prompt="$colored_prompt$before$WorkingDirColor$dir$LineColor$after"

    length=$(echo $prompt | wc -m)
    let fill_count=$COLUMNS-$length
  9. ByScripts renamed this gist Aug 25, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion bash_git → .bash_git.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    # To use, download this file at the root of your home directory, than add :
    # . .bash_git.bashrc
    # . .bash_git.sh
    # at the end of you .bashrc file

    Color_Off="\e[0m" # Text Reset
  10. ByScripts renamed this gist Aug 25, 2012. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  11. ByScripts renamed this gist Aug 25, 2012. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  12. ByScripts renamed this gist Aug 25, 2012. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions .bash_git → .git.bashrc
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,7 @@
    # To use, download this file at the root of your home directory, than add :
    # . .bash_git.bashrc
    # at the end of you .bashrc file

    Color_Off="\e[0m" # Text Reset
    Cyan="\e[0;36m" # Cyan
    Red="\e[1;31m" # Bold Red
  13. ByScripts created this gist Aug 25, 2012.
    73 changes: 73 additions & 0 deletions .bash_git
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,73 @@
    Color_Off="\e[0m" # Text Reset
    Cyan="\e[0;36m" # Cyan
    Red="\e[1;31m" # Bold Red
    Green="\e[1;32m" # Bold Green
    Yellow="\e[0;93m" # Yellow
    Blue="\e[0;94m" # Blue
    ICyan="\e[0;96m" # Intense Cyan

    function getShortWorkingDirectory {
    escaped_home=$(echo $HOME | sed -e 's/[\/&]/\\&/g')
    short_working_directory=$(pwd | sed -e "s/$escaped_home/~/g")
    echo $short_working_directory
    }

    function getGitBranch {
    echo $(__git_ps1 "%s")
    }

    function getGitStatus {

    if [[ $(getGitBranch) != "" ]]; then
    git status | grep "nothing to commit" > /dev/null 2>&1
    if [[ $? -eq 0 ]]; then
    echo "ok"
    else
    echo "nok"
    fi
    else
    echo "nogit"
    fi
    }

    function gitPrompt {
    dir=$(getShortWorkingDirectory)
    branch=$(getGitBranch)
    status=$(getGitStatus)
    time=$(date +%H:%M:%S)
    before="───┤ "
    after=" ├───"

    prompt="┌$before$time$after"
    colored_prompt="$Cyan┌$before$ICyan$time$Cyan$after"

    if [[ $status != "nogit" ]]; then
    prompt="$prompt$before"
    colored_prompt="$colored_prompt$before"
    if [[ $status == "ok" ]]; then
    prompt="$prompt ✓ $branch"
    colored_prompt="$colored_prompt $Green✓ $branch"
    else
    prompt="$prompt ✕ $branch"
    colored_prompt="$colored_prompt $Red✕ $branch"
    fi
    prompt="$prompt$after"
    colored_prompt="$colored_prompt$Cyan$after"
    fi

    prompt="$prompt$before$dir$after"
    colored_prompt="$colored_prompt$before$Yellow$dir$Cyan$after"

    length=$(echo $prompt | wc -m)
    let fill_count=$COLUMNS-$length

    while [[ $fill_count -gt 0 ]]; do
    prompt="$prompt─"
    colored_prompt="$colored_prompt─"
    let fill_count=$fill_count-1
    done
    echo -e $colored_prompt
    echo -ne "└─▶ "
    }

    export PS1="\$(gitPrompt)"