]> Frank Brehm's Git Trees - pixelpark/create-vmware-tpl.git/commitdiff
Adding files/fbr.sh
authorFrank Brehm <frank.brehm@pixelpark.com>
Wed, 2 May 2018 11:14:31 +0000 (13:14 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Wed, 2 May 2018 11:14:31 +0000 (13:14 +0200)
files/fbr.sh [new file with mode: 0644]

diff --git a/files/fbr.sh b/files/fbr.sh
new file mode 100644 (file)
index 0000000..47b9cdb
--- /dev/null
@@ -0,0 +1,88 @@
+#!/bin/bash
+
+# If not running interactively, don't do anything
+[ -z "$PS1" ] && return
+
+# Check for bash
+[ -z "$BASH_VERSION" ] && return
+
+# hold these special chars when piping to less
+export LESS="--RAW-CONTROL-CHARS"
+
+# check the window size after each command and, if necessary,
+# update the values of LINES and COLUMNS.
+shopt -s checkwinsize
+
+# make less more friendly for non-text input files, see lesspipe(1)
+[[ -x /bin/lesspipe ]] && eval "$(SHELL=/bin/sh lesspipe)"
+
+prompt_status() {
+    local e=$?;
+    [[ $e != 0 ]] && echo -e "$e ";
+}
+
+fbr() {
+
+    HISTFILE=~/.bash_fbrhistory
+    HISTSIZE=100000
+    HISTFILESIZE=100000
+    HISTTIMEFORMAT='%Y-%m-%d %H:%M:%S '
+    HISTCONTROL=ignoredups:ignorespace
+    history -n
+
+    if type -t __git_ps1 >/dev/null ; then
+        if [[ "$UID" = 0 ]]; then
+            PS1='\[\e[31m\]$(prompt_status)\[\033[01;31m\]\u\[\033[01;33m\]@\[\033[01;36m\]\h \[\033[01;33m\]\w\[\033[01;31m\]$(__git_ps1)\[\033[01;35m\] \$ \[\033[00m\]'
+        else
+            PS1='\[\e[31m\]$(prompt_status)\[\033[01;32m\]\u\[\033[01;33m\]@\[\033[01;36m\]\h \[\033[01;33m\]\w\[\033[01;31m\]$(__git_ps1)\[\033[01;35m\] > \[\033[00m\]'
+        fi
+    else
+        if [[ "$UID" = 0 ]]; then
+            PS1='\[\e[31m\]$(prompt_status)\[\033[01;31m\]\u\[\033[01;33m\]@\[\033[01;36m\]\h \[\033[01;33m\]\w \[\033[01;35m\]\$ \[\033[00m\]'
+        else
+            PS1='\[\e[31m\]$(prompt_status)\[\033[01;32m\]\u\[\033[01;33m\]@\[\033[01;36m\]\h \[\033[01;33m\]\w \[\033[01;35m\]> \[\033[00m\]'
+        fi
+    fi
+    PROMPT_COMMAND='history -a'
+    case $TERM in
+        xterm*|rxvt*)
+            PROMPT_COMMAND='history -a; printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
+            ;;
+        screen)
+            PROMPT_COMMAND='history -a; printf "\033]0;%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
+            ;;
+    esac
+
+    alias ls='ls --color=auto'
+
+    alias ..='cd ..'
+    alias ...='cd ../..'
+    alias cd..='cd ..'
+    alias cd...='cd ../..'
+    alias l='ls -l'
+    alias la='ls -la'
+    alias ll='ls -lA'
+    alias md='mkdir -p'
+
+    unalias cp 2>/dev/null || true
+    unalias mv 2>/dev/null || true
+    unalias rm 2>/dev/null || true
+
+    if type -t whoami >/dev/null; then
+        alias pl="ps -fu $(whoami)"
+    fi
+    alias rd='rmdir'
+
+    if [[ -x /bin/vim ]] ; then
+        alias vi="vim"
+        alias view="vim -R"
+    fi
+
+    if [[ "$(type -t colordiff)" = "file" ]] ; then
+        alias diff="$(type -p colordiff)"
+    fi
+
+}
+
+
+# vim: ts=4 et