From a766685321f35f131863041e10d8a36e4814eab0 Mon Sep 17 00:00:00 2001 From: Kévin Le Gouguec Date: Fri, 4 Nov 2016 18:29:48 +0100 Subject: Add initial script --- .bashprompt | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 .bashprompt diff --git a/.bashprompt b/.bashprompt new file mode 100644 index 0000000..2e0ba7d --- /dev/null +++ b/.bashprompt @@ -0,0 +1,98 @@ +__set-title () +{ + local title + local path=$(git root 2> /dev/null) + + if [ -n "${path}" ] + then + title=$(basename ${path}) + else + title="${USER}:${PWD/~/\~}" + fi + + echo -ne "\033]2;${title}\007" +} + +__fontify () +{ + local -A codes + codes[red]='31' + codes[green]='32' + codes[blue]='34' + codes[white]='37' + codes[bold]='1' + codes[dim]='2' + codes[clear]='0' + + local string=$1 + shift + + # We need to add \[ \] around CSI sequences so that Bash can tell which + # characters are non-printing. + + echo -en '\[\033[' + + local attributes=($@) + local nb=$# + + for ((i=0; i