From 1e9c2fdf6f8072002ef775a72c794170a7cea915 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 27 Nov 2012 00:12:43 -0500 Subject: largely redo my bash config --- .config/bash/aliases.sh | 3 +- .config/bash/rc.sh | 102 +++++++++++++++++++++++++----------------------- 2 files changed, 54 insertions(+), 51 deletions(-) (limited to '.config/bash') diff --git a/.config/bash/aliases.sh b/.config/bash/aliases.sh index 8241b95..f47bf4c 100644 --- a/.config/bash/aliases.sh +++ b/.config/bash/aliases.sh @@ -53,7 +53,6 @@ unset redshift ###################################################################### # Some almost-function aliases # ###################################################################### -xterm-title() { echo "];$@"; } # Oh, wait this one *is* a function alias lock="clear; away -C 'This terminal is locked'" -alias plock="xterm-title Terminal Locked;lock" +alias plock="term-title Terminal Locked;lock" mvln() { mv $1 $2; ln -s $2 $1; } diff --git a/.config/bash/rc.sh b/.config/bash/rc.sh index ed55f75..bfba6d4 100644 --- a/.config/bash/rc.sh +++ b/.config/bash/rc.sh @@ -1,80 +1,84 @@ # ~/.bashrc: executed by bash(1) for non-login shells. -# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) -# for examples - # I include this file for all interactive invocations of bash(1), whether # they are login shells or not. # If not running interactively, don't do anything -[ -z "$PS1" ] && return +[[ $- != *i* ]] && return + +# set variable identifying the chroot you work in (used in the prompt below) +if [[ -z "$debian_chroot" ]] && [[ -r /etc/debian_chroot ]]; then + debian_chroot="$(cat /etc/debian_chroot)" +fi -# don't put duplicate lines in the history. See bash(1) for more options +# Why is this not on by default? +# "We have a cached value, but it isn't valid anymore. Should we trash it?" +# "Duh, yes!" +shopt -s checkhash + +################################################################################ + +# History settings export HISTCONTROL=ignoredups export HISTFILE=${XDG_CACHE_HOME}/bash/history export HISTTIMEFORMAT='[%Y-%m-%d %H:%M] ' shopt -s histappend # append to the history file, don't overwrite it +mkdir -p "${HISTFILE%/*}" +# General settings shopt -s checkwinsize # update the values of LINES and COLUMNS shopt -s globstar # Let ** recursively scan directories +PROMPT_COMMAND='' -# Why is this not on by default? -# "We have a cached value, but it isn't valid anymore. Should we trash it?" -shopt -s checkhash - -# make less more friendly for non-text input files, see lesspipe(1) -[ -x "`which lesspipe 2>/dev/null`" ] && eval "$(SHELL=/bin/sh lesspipe)" +################################################################################ +# Overly complicated setting of PS1 # +################################################################################ -# set variable identifying the chroot you work in (used in the prompt below) -if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then - debian_chroot=$(cat /etc/debian_chroot) -fi +# Belongs in aliases, but I use it here +term-title() { + local fmt='' + case "$TERM" in + screen|tmux) fmt='\ek%s\e\\';; + xterm*|rxvt*) fmt='\e]0;%s\a';; + esac + printf "$fmt" "$*" +} make_prompt() { - local RESET='' - local BOLD='' - local GREEN='' - local BLUE='' - if $1; then - RESET="$(tput sgr0)" - BOLD="$(tput bold)" - GREEN="$(tput setaf 2)" - BLUE="$(tput setaf 4)" - fi - local CHROOT='${debian_chroot:+($debian_chroot)}' - echo "${RESET}${BOLD}${CHROOT}${GREEN}"'\u@\h'"${RESET}:${BOLD}${BLUE}"'\w'"${RESET}" + local _CHROOT='${debian_chroot:+($debian_chroot)}' + echo "${BOLD}${_CHROOT}${GREEN}\u@\h${RESET}${BOLD}${BLUE}:\w${RESET}" } -if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then +if [[ -x /usr/bin/tput ]] && tput setaf 1 >&/dev/null; then # We have color support; assume it's compliant with Ecma-48 # (ISO/IEC-6429). (Lack of such support is extremely rare, and such # a case would tend to support setf rather than setaf.) - PS1="$(make_prompt true )"'\n\$ ' + RESET="$(tput sgr0)" + BOLD="$(tput bold)" + RED="$(tput setaf 1)" + GREEN="$(tput setaf 2)" + BLUE="$(tput setaf 4)" + + _STATUS="${BOLD}[" + _STATUS+='$(v=$?; if [[ $v = 0 ]]; then c='"'${GREEN}'"'; else c='"${RED}"'; fi; printf %s%03i $c $v)' + _STATUS+="${RESET}${BOLD}]${RESET}" else - PS1="$(make_prompt false)"'\n\$ ' + _STATUS='[$?]' fi - -# If this is an xterm set the title to user@host:dir -case "$TERM" in - xterm*|rxvt*) - PS1="\[\e]0;$(make_prompt false)\a\]$PS1";; -esac - +PS1="${_STATUS} $(make_prompt)"'\n\$ ' +unset RESET BOLD RED GREEN BLUE _STATUS use_color +PS1="$(term-title $(make_prompt))$PS1" unset make_prompt -# Include modular config files -if [ -d "${XDG_CONFIG_HOME}/rc.d" ]; then - for file in "${XDG_CONFIG_HOME}/rc.d"/*.sh; do - . "$file" - done -fi +################################################################################ -if [ -f ${XDG_CONFIG_HOME}/bash/aliases.sh ]; then +# Load my alaises +if [[ -f ${XDG_CONFIG_HOME}/bash/aliases.sh ]]; then . ${XDG_CONFIG_HOME}/bash/aliases.sh fi -# enable programmable completion features (you don't need to enable -# this, if it's already enabled in /etc/bash.bashrc and /etc/profile -# sources /etc/bash.bashrc). -if [ -f /etc/bash_completion ]; then - . /etc/bash_completion +# Include modular config files +if [[ -d ${XDG_CONFIG_HOME}/bash/rc.d ]]; then + for file in "${XDG_CONFIG_HOME}/bash/rc.d"/*.sh; do + . "$file" + done fi -- cgit v1.2.3-2-g168b From 906b645cdb3286076affbb942ff23d99e409db86 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 4 Jan 2013 10:42:16 -0500 Subject: enlarge Bash's HISTSIZE (500 -> 5000) --- .config/bash/rc.sh | 1 + 1 file changed, 1 insertion(+) (limited to '.config/bash') diff --git a/.config/bash/rc.sh b/.config/bash/rc.sh index bfba6d4..faf8116 100644 --- a/.config/bash/rc.sh +++ b/.config/bash/rc.sh @@ -21,6 +21,7 @@ shopt -s checkhash export HISTCONTROL=ignoredups export HISTFILE=${XDG_CACHE_HOME}/bash/history export HISTTIMEFORMAT='[%Y-%m-%d %H:%M] ' +export HISTSIZE=5000 shopt -s histappend # append to the history file, don't overwrite it mkdir -p "${HISTFILE%/*}" -- cgit v1.2.3-2-g168b From f2282f6cc0011fc761986c0e3b4e3735d4629e81 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 26 Jan 2013 22:02:06 -0500 Subject: avoid bug in sed 4.2.2 --- .config/bash/aliases.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to '.config/bash') diff --git a/.config/bash/aliases.sh b/.config/bash/aliases.sh index f47bf4c..0964a83 100644 --- a/.config/bash/aliases.sh +++ b/.config/bash/aliases.sh @@ -37,7 +37,7 @@ alias l='ls -CF' ###################################################################### #alias rm='gvfs-trash' alias ssh='ssh -XC' -alias sed='sed --follow-symlinks' +#alias sed='sed --follow-symlinks' # breaks sed 4.2.2 alias tree='tree --charset utf8' alias cd=pushd alias gitk='gitk --all --date-order' -- cgit v1.2.3-2-g168b From 61471be038223fc8610eb75ea8381a6237ae8b6c Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 8 Apr 2013 10:05:34 -0400 Subject: use tabs in .config/bash/aliases.sh --- .config/bash/aliases.sh | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to '.config/bash') diff --git a/.config/bash/aliases.sh b/.config/bash/aliases.sh index 0964a83..3f39107 100644 --- a/.config/bash/aliases.sh +++ b/.config/bash/aliases.sh @@ -6,23 +6,23 @@ # Set up colors and settings for ls/dir/vdir # ###################################################################### if [ -x "`which dircolors`" ]; then - eval "`dircolors -b`" - alias ls='ls -1v --color=auto' - alias dir='dir -v --color=auto' - alias vdir='vdir -v--color=auto' + eval "`dircolors -b`" + alias ls='ls -1v --color=auto' + alias dir='dir -v --color=auto' + alias vdir='vdir -v--color=auto' - for xgrep in ${PATH//:/\/*grep }/*grep; do - if [ -f "$xgrep" ]; then - xgrep=`basename "$xgrep"` - if [ "$xgrep" != pgrep ]; then - alias $xgrep="$xgrep --color=auto" - fi - fi - done + for xgrep in ${PATH//:/\/*grep }/*grep; do + if [ -f "$xgrep" ]; then + xgrep=`basename "$xgrep"` + if [ "$xgrep" != pgrep ]; then + alias $xgrep="$xgrep --color=auto" + fi + fi + done else - alias ls='ls -1v' - alias dir='dir -v' - alias vdir='vdir -v' + alias ls='ls -1v' + alias dir='dir -v' + alias vdir='vdir -v' fi ###################################################################### -- cgit v1.2.3-2-g168b From ccefe3e3923a28887b96ba564cd6a4d3963f4b95 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 8 Apr 2013 10:06:21 -0400 Subject: remove ssh bash alias --- .config/bash/aliases.sh | 1 - 1 file changed, 1 deletion(-) (limited to '.config/bash') diff --git a/.config/bash/aliases.sh b/.config/bash/aliases.sh index 3f39107..aabd073 100644 --- a/.config/bash/aliases.sh +++ b/.config/bash/aliases.sh @@ -36,7 +36,6 @@ alias l='ls -CF' # Some preferences for miscellaneous stuff # ###################################################################### #alias rm='gvfs-trash' -alias ssh='ssh -XC' #alias sed='sed --follow-symlinks' # breaks sed 4.2.2 alias tree='tree --charset utf8' alias cd=pushd -- cgit v1.2.3-2-g168b From 173c3cf1859b2adcae5abd534f31bdd8018d2a7e Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 8 Apr 2013 10:07:03 -0400 Subject: fix quoting in _STATUS in .config/bash/rc.sh --- .config/bash/rc.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to '.config/bash') diff --git a/.config/bash/rc.sh b/.config/bash/rc.sh index faf8116..90e5b2d 100644 --- a/.config/bash/rc.sh +++ b/.config/bash/rc.sh @@ -60,7 +60,7 @@ if [[ -x /usr/bin/tput ]] && tput setaf 1 >&/dev/null; then BLUE="$(tput setaf 4)" _STATUS="${BOLD}[" - _STATUS+='$(v=$?; if [[ $v = 0 ]]; then c='"'${GREEN}'"'; else c='"${RED}"'; fi; printf %s%03i $c $v)' + _STATUS+="\$(v=\$?; if [[ \$v = 0 ]]; then c='${GREEN}'; else c='${RED}'; fi; printf %s%03i \$c \$v)" _STATUS+="${RESET}${BOLD}]${RESET}" else _STATUS='[$?]' -- cgit v1.2.3-2-g168b From 2bf75c12593d8b1c70369c44a26dd478537c89e9 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 14 Aug 2013 10:38:50 -0400 Subject: bash/rc.sh: clean up PS1 --- .config/bash/rc.sh | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to '.config/bash') diff --git a/.config/bash/rc.sh b/.config/bash/rc.sh index 90e5b2d..dee42b4 100644 --- a/.config/bash/rc.sh +++ b/.config/bash/rc.sh @@ -5,11 +5,6 @@ # If not running interactively, don't do anything [[ $- != *i* ]] && return -# set variable identifying the chroot you work in (used in the prompt below) -if [[ -z "$debian_chroot" ]] && [[ -r /etc/debian_chroot ]]; then - debian_chroot="$(cat /etc/debian_chroot)" -fi - # Why is this not on by default? # "We have a cached value, but it isn't valid anymore. Should we trash it?" # "Duh, yes!" @@ -45,11 +40,10 @@ term-title() { } make_prompt() { - local _CHROOT='${debian_chroot:+($debian_chroot)}' - echo "${BOLD}${_CHROOT}${GREEN}\u@\h${RESET}${BOLD}${BLUE}:\w${RESET}" + echo "${BOLD}${GREEN}\u@\h${BLUE}:\w${RESET}" } -if [[ -x /usr/bin/tput ]] && tput setaf 1 >&/dev/null; then +if tput setaf 1 &>/dev/null; then # We have color support; assume it's compliant with Ecma-48 # (ISO/IEC-6429). (Lack of such support is extremely rare, and such # a case would tend to support setf rather than setaf.) @@ -60,13 +54,13 @@ if [[ -x /usr/bin/tput ]] && tput setaf 1 >&/dev/null; then BLUE="$(tput setaf 4)" _STATUS="${BOLD}[" - _STATUS+="\$(v=\$?; if [[ \$v = 0 ]]; then c='${GREEN}'; else c='${RED}'; fi; printf %s%03i \$c \$v)" + _STATUS+="\$(v=\$?; [[ \$v = 0 ]] && c='${GREEN}' || c='${RED}'; printf %s%03i \$c \$v)" _STATUS+="${RESET}${BOLD}]${RESET}" else _STATUS='[$?]' fi PS1="${_STATUS} $(make_prompt)"'\n\$ ' -unset RESET BOLD RED GREEN BLUE _STATUS use_color +unset RESET BOLD RED GREEN BLUE _STATUS PS1="$(term-title $(make_prompt))$PS1" unset make_prompt -- cgit v1.2.3-2-g168b From 4652fb938285ad72a3d21042c118361969176f80 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 14 Aug 2013 15:47:40 -0400 Subject: touch up the first line in .config/bash/rc.sh and .config/login.sh --- .config/bash/rc.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to '.config/bash') diff --git a/.config/bash/rc.sh b/.config/bash/rc.sh index dee42b4..447796a 100644 --- a/.config/bash/rc.sh +++ b/.config/bash/rc.sh @@ -1,4 +1,4 @@ -# ~/.bashrc: executed by bash(1) for non-login shells. +# ~/.bashrc: executed by bash(1) for interactive non-login shells. # I include this file for all interactive invocations of bash(1), whether # they are login shells or not. -- cgit v1.2.3-2-g168b