From 3bd42d9ee4c41cd8a9c7749e8079ad80945c1910 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Wed, 2 May 2018 13:14:31 +0200 Subject: [PATCH] Adding files/fbr.sh --- files/fbr.sh | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 files/fbr.sh diff --git a/files/fbr.sh b/files/fbr.sh new file mode 100644 index 0000000..47b9cdb --- /dev/null +++ b/files/fbr.sh @@ -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 -- 2.39.5