Skip to content

Commit

Permalink
move the prompt back
Browse files Browse the repository at this point in the history
  • Loading branch information
phunehehe committed Dec 10, 2013
1 parent e86c424 commit d6dcdac
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 60 deletions.
6 changes: 1 addition & 5 deletions _bashrc
@@ -1,7 +1,5 @@
#!/bin/bash

. ~/.shrc


export HISTCONTROL=erasedups
export HISTSIZE=10000
Expand All @@ -12,10 +10,8 @@ shopt -s globstar
prompt_escape() {
echo "\[$1\]"
}

prompt_date='\D{%H:%M:%S}'

. ~/bin/bash-prompt
. ~/.shrc
PROMPT_COMMAND=my_prompt


Expand Down
54 changes: 54 additions & 0 deletions _shrc
Expand Up @@ -58,4 +58,58 @@ local_config="$HOME/.shrc-local"
test -f "$local_config" && . "$local_config"



# Le prompt


date_color="$(prompt_escape $(tput setaf 248))"
cwd_color="$(prompt_escape $(tput setaf 38))"
jobs_color="$(prompt_escape "$(tput setab 221)$(tput setaf 16)")"
end_jobs_color="$(prompt_escape $(tput setab 0))"
code_color="$(prompt_escape "$(tput setab 203)$(tput setaf 16)")"
end_code_color="$(prompt_escape $(tput setab 0))"
bold="$(prompt_escape $(tput bold))"
end_bold="$(prompt_escape $(tput sgr0))"


if test "$EUID" = 0
then
host_color="$(prompt_escape $(tput setaf 203))"
elif test -n "$SSH_TTY" || test -n "$SUDO_USER"
then
host_color="$(prompt_escape $(tput setaf 221))"
else
host_color="$(prompt_escape $(tput setaf 47))"
fi
host_piece="$host_color$(whoami)@$(hostname)"

date_piece="$date_color$prompt_date"


my_prompt() {

previous_code=$?

pieces="$date_piece $host_piece"

working_dir="$PWD"
slashes="${working_dir//[^\/]}"
if ((${#slashes} > 3))
then
for i in $(seq 3 ${#slashes})
do
working_dir="${working_dir#*/}"
done
fi
pieces="$pieces $cwd_color$working_dir"

number_of_jobs=$(jobs | grep '^\[' | wc -l)
(($number_of_jobs > 0)) && pieces="$pieces $jobs_color$number_of_jobs$end_jobs_color"

(($previous_code > 0)) && pieces="$pieces $code_color$previous_code$end_code_color"

PS1="$bold$pieces$end_bold "
}


true
6 changes: 1 addition & 5 deletions _zshrc
@@ -1,7 +1,5 @@
#!/bin/zsh

. ~/.shrc


export HISTSIZE=10000
export SAVEHIST=$HISTSIZE
Expand All @@ -17,10 +15,8 @@ setopt EXTENDED_GLOB
prompt_escape() {
echo "%{$1%}"
}

prompt_date='%D{%H:%M:%S}'

. ~/bin/bash-prompt
. ~/.shrc
precmd_functions=(my_prompt)


Expand Down
50 changes: 0 additions & 50 deletions bin/bash-prompt

This file was deleted.

0 comments on commit d6dcdac

Please sign in to comment.