@@ -36,8 +36,8 @@ declare -a BASHRC_VERSIONINFO
3636BASHRC_VERSIONINFO[0]=1 # Major version
3737BASHRC_VERSIONINFO[1]=2 # Minor version
3838BASHRC_VERSIONINFO[2]=5 # Micro version
39- BASHRC_VERSIONINFO[3]=0 # Patch ID
40- BASHRC_VERSIONINFO[4]=" beta " # Release type
39+ BASHRC_VERSIONINFO[3]=2 # Patch ID
40+ BASHRC_VERSIONINFO[4]=" stable " # Release type
4141
4242export BASHRC_VERSIONINFO
4343BASHRC_VERSION=" ${BASHRC_VERSIONINFO[0]} .\
@@ -301,16 +301,56 @@ function loadRcDir() {
301301 fi
302302}
303303
304+ lastcmd () {
305+ LASTCMD=$( history 1 | cut -c8-) ;
306+ echo -ne " \e]2;$LASTCMD \a\e]1;$LASTCMD \a" ;
307+
308+ branch=$( getGitBranch)
309+
310+ export PS1=" \n[${eLIGHTGREEN} \t${eNC} ] :: [${eLIGHTBLUE} \w${eNC} ] $branch \n${eLIGHTGREEN} \u${eWHITE} @${eLIGHTGREEN} \h${eWHITE} >${eNC} "
311+ }
312+
313+ # Returns the checked out branch of a git repository you are inside of
314+ # Doesn't do anything if git is not installed
315+ function getGitBranch() {
316+
317+ if hash git 2> /dev/null; then
318+ gitBranch=$( git rev-parse --abbrev-ref HEAD 2> /dev/null)
319+ else
320+ gitBranch=' '
321+ fi
322+
323+ gitBranch=$( git rev-parse --abbrev-ref HEAD 2> /dev/null)
324+
325+ if [ $( echo ${# gitBranch} ) -gt 0 ]; then
326+
327+ branch=" $gitBranch "
328+ else
329+ branch=' ' ;
330+ fi
331+
332+ echo $branch
333+
334+ }
335+
336+ PROMPT_COMMAND=lastcmd
337+
338+
304339# Sets the terminal title
340+ #
341+ # -- This functionality has been removed because it can cause command line redirects
342+ # to write files (>, |, etc) can cause the command and part of the prompt to be written
343+ # to disk
344+ #
305345# TODO: Update SetTitle so it doesn't output anything if the terminal won't handle it intelligently
306346# TODO: Fix this to escape command names before output to prevent possible unintended command execution
307- function SetTitle() {
308- unset PROMPT_COMMAND
309- PROMPT_COMMAND=" echo -ne \" \033]0;\" $@ \" ($USER @$HOSTNAME )\007\" ;\
310- echo -ne \" \033]1;\" $@ \" ($USER @$HOSTNAME )\007\" ;\
311- unset PROMPT_COMMAND"
347+ # function SetTitle() {
348+ # unset PROMPT_COMMAND
349+ # PROMPT_COMMAND="echo -ne \"\033]0;\"$@\" ($USER@$HOSTNAME)\007\";\
350+ # echo -ne \"\033]1;\"$@\" ($USER@$HOSTNAME)\007\";\
351+ # unset PROMPT_COMMAND"
312352
313- }
353+ # }
314354# # OUTPUT FUNCTIONS
315355# ###############################################################################
316356# Helper functions for writing different kinds of messages to the user.
@@ -440,11 +480,11 @@ if ! shopt -oq posix; then
440480fi
441481
442482# Set terminal title to the running command
443- export U_UPDATETITLE=${U_UPDATETITLE:- " 1" }
444- if [ " ${U_UPDATETITLE} " == " 1" ]; then
445- set -o functrace
446- trap ' SetTitle "$BASH_COMMAND"' DEBUG
447- fi
483+ # export U_UPDATETITLE=${U_UPDATETITLE:-"1"}
484+ # if [ "${U_UPDATETITLE}" == "1" ]; then
485+ # set -o functrace
486+ # trap 'SetTitle "$BASH_COMMAND"' DEBUG
487+ # fi
448488
449489ErrorMsg -ne " Module support: \t"
450490if [ " ${U_MODULES_ENABLE} " == " 1" ]; then
@@ -463,5 +503,7 @@ if [ "${U_POSTCUSTOM}" == "1" ]; then
463503
464504fi
465505
506+
466507emsg " Loaded bashrc $BASHRC_VERSION "
467- SetTitle $U_DEFAULT_TITLE
508+ # SetTitle $U_DEFAULT_TITLE
509+
0 commit comments