From 0c1065de4858fb868b36126ec60d5a31c218297e Mon Sep 17 00:00:00 2001 From: CyberLeo Date: Sun, 2 Jan 2011 12:44:38 -0600 Subject: [PATCH] Current work --- bash-config/bash_profile | 4 ++++ bash-config/bash_profile.d/10-inputrc | 6 ++++++ bash-config/bash_profile.d/10-local-bin | 4 ++++ bash-config/bash_profile.d/10-prompt | 3 +++ bash-config/bash_profile.d/10-title | 17 +++++++++++++++++ bash-config/bash_profile.d/20-flag | 17 +++++++++++++++++ bash-config/bash_profile.d/98-dot-bash-profile | 4 ++++ bash-config/bash_profile.d/99-bashrc | 3 +++ bash-config/bashrc | 4 ++++ bash-config/bashrc.d/10-aliases | 7 +++++++ bash-config/bashrc.d/99-dot-bashrc | 4 ++++ bash-config/common | 9 +++++++++ bash-config/inputrc | 17 +++++++++++++++++ bash-config/virgin | 1 + 14 files changed, 100 insertions(+) create mode 100644 bash-config/bash_profile create mode 100644 bash-config/bash_profile.d/10-inputrc create mode 100644 bash-config/bash_profile.d/10-local-bin create mode 100644 bash-config/bash_profile.d/10-prompt create mode 100644 bash-config/bash_profile.d/10-title create mode 100644 bash-config/bash_profile.d/20-flag create mode 100644 bash-config/bash_profile.d/98-dot-bash-profile create mode 100644 bash-config/bash_profile.d/99-bashrc create mode 100644 bash-config/bashrc create mode 100644 bash-config/bashrc.d/10-aliases create mode 100644 bash-config/bashrc.d/99-dot-bashrc create mode 100644 bash-config/common create mode 100644 bash-config/inputrc create mode 100755 bash-config/virgin diff --git a/bash-config/bash_profile b/bash-config/bash_profile new file mode 100644 index 0000000..1a6fb67 --- /dev/null +++ b/bash-config/bash_profile @@ -0,0 +1,4 @@ +_base="/usr/local/etc/bash-config" +_self="bash_profile" + +source "${_base}/common" diff --git a/bash-config/bash_profile.d/10-inputrc b/bash-config/bash_profile.d/10-inputrc new file mode 100644 index 0000000..fea4743 --- /dev/null +++ b/bash-config/bash_profile.d/10-inputrc @@ -0,0 +1,6 @@ +# Set up inputrc in environment + +[ -f "${HOME}/.inputrc" ] && INPUTRC="${HOME}/.inputrc" +[ -z "${INPUTRC}" -a -f "/etc/inputrc" ] && INPUTRC="/etc/inputrc" +[ -z "${INPUTRC}" -a -f "/usr/local/etc/inputrc" ] && INPUTRC="/usr/local/etc/inputrc" +[ -z "${INPUTRC}" -a -f "/usr/local/etc/bash-config/inputrc" ] && INPUTRC="/usr/local/etc/bash-config/inputrc" diff --git a/bash-config/bash_profile.d/10-local-bin b/bash-config/bash_profile.d/10-local-bin new file mode 100644 index 0000000..7bfa752 --- /dev/null +++ b/bash-config/bash_profile.d/10-local-bin @@ -0,0 +1,4 @@ +# Add ~/bin and ~/sbin to PATH + +[ -d "${HOME}/sbin" ] && PATH="${HOME}/sbin:${PATH}" +[ -d "${HOME}/bin" ] && PATH="${HOME}/bin:${PATH}" diff --git a/bash-config/bash_profile.d/10-prompt b/bash-config/bash_profile.d/10-prompt new file mode 100644 index 0000000..7aa9e85 --- /dev/null +++ b/bash-config/bash_profile.d/10-prompt @@ -0,0 +1,3 @@ +# Set a sensible default prompt + +PS1="[\u@\h \w]\$ " diff --git a/bash-config/bash_profile.d/10-title b/bash-config/bash_profile.d/10-title new file mode 100644 index 0000000..ea3fadb --- /dev/null +++ b/bash-config/bash_profile.d/10-title @@ -0,0 +1,17 @@ +# Change the window title of X terminals + +_i || return + +# Define the title string. Use single-quotes here, to avoid expanding right now. +title_string='${HOSTNAME%%.*}(${USER})' + +case ${TERM} in +xterm*|rxvt*|Eterm|aterm|kterm|gnome*|interix) + PROMPT_COMMAND='printf "\033]0;'"${title_string}"'\007"' + ;; +screen) + PROMPT_COMMAND='printf "\033_'"${title_string}"'\033\134"' + ;; +esac + +unset title_string diff --git a/bash-config/bash_profile.d/20-flag b/bash-config/bash_profile.d/20-flag new file mode 100644 index 0000000..4138b68 --- /dev/null +++ b/bash-config/bash_profile.d/20-flag @@ -0,0 +1,17 @@ +# Add a machine-hostname-based color flag to the prompt + +_i || return + +# Find the flag binary +flag_bin="%%LOCALBASE%%/bin/flag" +[ -x "${flag_bin}" ] || flag_bin="$(which flag 2>/dev/null)" +[ -x "${flag_bin}" ] || return + +# Import flag, if wanted +[ -f "${HOME}/.noflag" ] || FLAG="($(${flag_bin} -e))" + +# Patch flag into prompt, if not already there +[ "${FLAG}" ] && echo "${PS1}" | grep -q "${FLAG}" || PS1="${FLAG}${PS1}" + +# Clean up environment +unset flag_bin diff --git a/bash-config/bash_profile.d/98-dot-bash-profile b/bash-config/bash_profile.d/98-dot-bash-profile new file mode 100644 index 0000000..78416f1 --- /dev/null +++ b/bash-config/bash_profile.d/98-dot-bash-profile @@ -0,0 +1,4 @@ +# Source user's bash_profile, if it exists and isn't a symlink to myself +_prof="$(realpath "${HOME}/.bash_profile")" +[ -f "${_prof}" ] && echo "${_prof}" | grep -qv "^${_base}" && source "${_prof}" +unset _prof diff --git a/bash-config/bash_profile.d/99-bashrc b/bash-config/bash_profile.d/99-bashrc new file mode 100644 index 0000000..980d4fa --- /dev/null +++ b/bash-config/bash_profile.d/99-bashrc @@ -0,0 +1,3 @@ +# Bash doesn't automatically source bashrc after bash_profile, so we should + +source "${_base}/bashrc" diff --git a/bash-config/bashrc b/bash-config/bashrc new file mode 100644 index 0000000..52fb4a0 --- /dev/null +++ b/bash-config/bashrc @@ -0,0 +1,4 @@ +_base="/usr/local/etc/bash-config" +_self="bashrc" + +source "${_base}/common" diff --git a/bash-config/bashrc.d/10-aliases b/bash-config/bashrc.d/10-aliases new file mode 100644 index 0000000..e061a39 --- /dev/null +++ b/bash-config/bashrc.d/10-aliases @@ -0,0 +1,7 @@ +# A few sensible aliases + +_i || return + +alias pp='ps axopid,user,state,command' +alias ls='ls -G' +alias ll='ls -la' diff --git a/bash-config/bashrc.d/99-dot-bashrc b/bash-config/bashrc.d/99-dot-bashrc new file mode 100644 index 0000000..eb47e67 --- /dev/null +++ b/bash-config/bashrc.d/99-dot-bashrc @@ -0,0 +1,4 @@ +# Source user's bashrc, if it exists and isn't a symlink to myself +_prof="$(realpath "${HOME}/.bashrc")" +[ -f "${_prof}" ] && echo "${_prof}" | grep -qv "^${_base}" && source "${_prof}" +unset _prof diff --git a/bash-config/common b/bash-config/common new file mode 100644 index 0000000..667dec9 --- /dev/null +++ b/bash-config/common @@ -0,0 +1,9 @@ +# Set up _base, _self first + +# Interactive shell? +_i() { [[ $- == *i* ]]; return $?; } + +# Include all subfiles, in lexicographical order +eval $(find "${_base}/${_self}.d/" -type f | sort | sed -e 's/^/source /; s/$/;/') + +unset _base _self _i diff --git a/bash-config/inputrc b/bash-config/inputrc new file mode 100644 index 0000000..6f7925e --- /dev/null +++ b/bash-config/inputrc @@ -0,0 +1,17 @@ +set meta-flag on +set input-meta on +set convert-meta off +set output-meta on + +"\e[1~": beginning-of-line +"\e[4~": end-of-line +"\e[5~": beginning-of-history +"\e[6~": end-of-history +"\e[3~": delete-char +"\e[2~": quoted-insert +"\e[5C": forward-word +"\e[5D": backward-word + +# fix Home and End for German users +"\e[7~": beginning-of-line +"\e[8~": end-of-line diff --git a/bash-config/virgin b/bash-config/virgin new file mode 100755 index 0000000..c17a21f --- /dev/null +++ b/bash-config/virgin @@ -0,0 +1 @@ +env -i HOME="${HOME}" TERM="${TERM}" USER="${USER}" "$(which bash) --noprofile --norc -x -- 2.42.0