aboutsummaryrefslogtreecommitdiffstats
path: root/bash
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2021-06-25 12:56:30 +0200
committerMattias Andrée <maandree@kth.se>2021-06-25 12:56:30 +0200
commit5a7db2f34aa6a6787d98a001b6d28be97f36abf4 (patch)
tree52db199005cc5daee35b5c0e9b3d28b534449e1c /bash
downloaddotfiles-5a7db2f34aa6a6787d98a001b6d28be97f36abf4.tar.gz
dotfiles-5a7db2f34aa6a6787d98a001b6d28be97f36abf4.tar.bz2
dotfiles-5a7db2f34aa6a6787d98a001b6d28be97f36abf4.tar.xz
First commit
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--bash-completion/Makefile17
-rw-r--r--bash-completion/bash-aliases29
-rw-r--r--bash-completion/bash-bashrc3
-rw-r--r--bash/Makefile47
-rw-r--r--bash/aliases87
-rw-r--r--bash/aliases-Zenith17
-rw-r--r--bash/bashrc64
-rw-r--r--bash/bashrc_palette89
-rw-r--r--bash/bashrc_prompt413
-rw-r--r--bash/logout9
-rw-r--r--bash/profile17
11 files changed, 792 insertions, 0 deletions
diff --git a/bash-completion/Makefile b/bash-completion/Makefile
new file mode 100644
index 0000000..7d9fcc9
--- /dev/null
+++ b/bash-completion/Makefile
@@ -0,0 +1,17 @@
+.POSIX:
+
+install:
+ mkdir -p -- ~/.config/bash/aliases.d
+ mkdir -p -- ~/.config/bash/bashrc.d
+ test ! -d ~/.config/bash/aliases.d/bash-completion
+ test ! -d ~/.config/bash/bashrc.d/bash-completion
+ ln -sf -- ~/.dotfiles/bash-completion/bash-aliases ~/.config/bash/aliases.d/bash-completion
+ ln -sf -- ~/.dotfiles/bash-completion/bash-bashrc ~/.config/bash/bashrc.d/bash-completion
+
+uninstall:
+ -unlink -- ~/.config/bash/aliases.d/bash-completion
+ -unlink -- ~/.config/bash/bashrc.d/bash-completion
+ -rmdir -- ~/.config/bash/aliases.d
+ -rmdir -- ~/.config/bash/bashrc.d
+
+.PHONY: install uninstall
diff --git a/bash-completion/bash-aliases b/bash-completion/bash-aliases
new file mode 100644
index 0000000..92aab19
--- /dev/null
+++ b/bash-completion/bash-aliases
@@ -0,0 +1,29 @@
+# -*- shell-script -*-
+
+# DESCRIPTION: reload autocompletion scripts and load new ones
+# USAGE: recomplete
+
+recomplete () {
+ if test -f /etc/bash_completion && ! shopt -oq posix; then
+ . /etc/bash_completion
+ fi
+ if test -f /usr/share/bash-completion/bash_completion && ! shopt -oq posix; then
+ . /usr/share/bash-completion/bash_completion
+ fi
+ if test -d ~/.local/bash_completion.d ] && ! shopt -oq posix; then
+ for __completionscript in ~/.local/bash_completion.d/*; do
+ if test -r "${__completionscript}"; then
+ . "${__completionscript}"
+ fi
+ done
+ unset __completionscript
+ fi
+ if test -d ~/.local/share/bash_completion.d && ! shopt -oq posix; then
+ for __completionscript in ~/.local/share/bash_completion.d/*; do
+ if [ -r "${__completionscript}" ]; then
+ . "${__completionscript}"
+ fi
+ done
+ unset __completionscript
+ fi
+}
diff --git a/bash-completion/bash-bashrc b/bash-completion/bash-bashrc
new file mode 100644
index 0000000..5222094
--- /dev/null
+++ b/bash-completion/bash-bashrc
@@ -0,0 +1,3 @@
+# -*- shell-script -*-
+
+recomplete
diff --git a/bash/Makefile b/bash/Makefile
new file mode 100644
index 0000000..7ea782a
--- /dev/null
+++ b/bash/Makefile
@@ -0,0 +1,47 @@
+.POSIX:
+
+install:
+ mkdir -p -- ~/.var/cache
+ mkdir -p -- ~/.config/bash
+ touch -- ~/.var/cache/bash_history
+ test ! -d ~/.bash_history
+ test ! -d ~/.bash_logout
+ test ! -d ~/.bash_profile
+ test ! -d ~/.bashrc
+ test ! -d ~/.config/bash/logout
+ test ! -d ~/.config/bash/profile
+ test ! -d ~/.config/bash/bashrc
+ test ! -d ~/.config/bash/bashrc_palette
+ test ! -d ~/.config/bash/bashrc_prompt
+ test ! -d ~/.config/bash/aliases
+ test ! -d ~/.config/bash/aliases-Zenith
+ ln -sf -- .var/cache/bash_history ~/.bash_history
+ ln -sf -- .config/bash/logout ~/.bash_logout
+ ln -sf -- .config/bash/profile ~/.bash_profile
+ ln -sf -- .config/bash/bashrc ~/.bashrc
+ ln -sf -- ~/.dotfiles/bash/logout ~/.config/bash/logout
+ ln -sf -- ~/.dotfiles/bash/profile ~/.config/bash/profile
+ ln -sf -- ~/.dotfiles/bash/bashrc ~/.config/bash/bashrc
+ ln -sf -- ~/.dotfiles/bash/bashrc_palette ~/.config/bash/bashrc_palette
+ ln -sf -- ~/.dotfiles/bash/bashrc_prompt ~/.config/bash/bashrc_prompt
+ ln -sf -- ~/.dotfiles/bash/aliases ~/.config/bash/aliases
+ ln -sf -- ~/.dotfiles/bash/aliases-Zenith ~/.config/bash/aliases-Zenith
+
+uninstall:
+ -unlink -- ~/.bash_history
+ -unlink -- ~/.bash_logout
+ -unlink -- ~/.bash_profile
+ -unlink -- ~/.bashrc
+ -rm -f -- ~/.var/cache/bash_history
+ -unlink -- ~/.config/bash/logout
+ -unlink -- ~/.config/bash/profile
+ -unlink -- ~/.config/bash/bashrc
+ -unlink -- ~/.config/bash/bashrc_palette
+ -unlink -- ~/.config/bash/bashrc_prompt
+ -unlink -- ~/.config/bash/aliases
+ -unlink -- ~/.config/bash/aliases-Zenith
+ -rmdir -- ~/.config/bash/aliases.d
+ -rmdir -- ~/.config/bash/bashrc.d
+ -rmdir -- ~/.config/bash
+
+.PHONY: install uninstall
diff --git a/bash/aliases b/bash/aliases
new file mode 100644
index 0000000..140f958
--- /dev/null
+++ b/bash/aliases
@@ -0,0 +1,87 @@
+# -*- shell-script -*-
+
+# DESCRIPTION: Create directories and parents, if missing, and move into the first one
+# USAGE: mkcd <directory> [<additional directories to create>]
+mkcd () {
+ mkdir -p -- "$@"
+ cd -- "$1"
+}
+
+# DESCRIPTION: Start bash in a temporary directory and destroy it after exiting the new bash instance
+# USAGE: tmpsh
+tmpsh () (
+ local tmpdir
+ tmpdir="${XDG_RUNTIME_DIR}"
+ if test -z "$tmpdir"; then
+ tmpdir=/tmp
+ fi
+ tmpdir="$tmpdir/tmpsh-$$.d"
+ mkdir -p -- "$tmpdir"
+ cd -- "$tmpdir"
+ bash
+ cd /
+ rm -rf -- "$tmpdir"
+ test ! -e "$tmpdir"
+)
+
+#DESCRIPTION: Reload the shell configurations
+#USAGE: resh
+resh () {
+ . ~/.bashrc
+}
+
+#DESCRIPTION: Edit the shell configurations
+#USAGE: edsh
+edsh () {
+ if [ -z "$EDITOR" ]; then
+ echo 'No default editor is set, please configure the environment variable EDITOR'
+ else
+ $EDITOR ~/.bashrc
+ fi
+}
+
+# DESCRIPTION: Run a command in a infinite loop with a sleep between executions
+# USAGE: forever "<arguments for sleep>" <command>
+forever () {
+ time="$1"
+ shift 1
+ while true; do
+ "$@"
+ sleep $time
+ done
+}
+
+#DESCRIPTION: ls with long listing, classification with appendix character, hidden files and the . and .. directories
+alias ll='ls -alF'
+
+#DESCRIPTION: ls with hidden files
+alias la='ls -A'
+
+#DESCRIPTION: ls with classification with appendix character
+alias l='ls -CF'
+
+#DESCRIPTION: Go to the parent directory
+alias ..="cd .."
+
+
+
+#libnotify
+# DESCRIPTION: Add an "alert" alias for long running commands. Use like so: sleep 10; alert
+alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history | tail -n1 | sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
+
+
+
+for __script in ~/.config/bash/aliases.d/*; do
+ if test -r "${__script}"; then
+ . "${__script}"
+ fi
+done
+unset __script
+
+if test -r ~/.config/bash/"aliases-$(hostname)"; then
+ . ~/.config/bash/"aliases-$(hostname)"
+fi
+
+if test -r ~/work/.config/bash/aliases; then
+ . ~/work/.config/bash/aliases
+fi
diff --git a/bash/aliases-Zenith b/bash/aliases-Zenith
new file mode 100644
index 0000000..ac794c9
--- /dev/null
+++ b/bash/aliases-Zenith
@@ -0,0 +1,17 @@
+# -*- shell-script -*-
+
+mount-crypt () {
+ sudo printf '' && \
+ device="$(sudo losetup --show -f -P /media/Secondary/.crypt/crypt.img)" && \
+ printf '%s\n' "${device}" > "${XDG_RUNTIME_DIR}/CryptCrypt" && \
+ gpg --decrypt /media/Secondary/.crypt/crypt.key | sudo cryptsetup -d - open "${device}" CryptCrypt && \
+ mkdir -p ~/Crypt && \
+ sudo mount /dev/mapper/CryptCrypt ~/Crypt
+}
+
+umount-crypt () {
+ sudo umount ~/Crypt
+ rmdir ~/Crypt
+ sudo cryptsetup close CryptCrypt
+ sudo losetup --detach "$(cat -- "${XDG_RUNTIME_DIR}/CryptCrypt")"
+}
diff --git a/bash/bashrc b/bash/bashrc
new file mode 100644
index 0000000..a500a9d
--- /dev/null
+++ b/bash/bashrc
@@ -0,0 +1,64 @@
+# -*- shell-script -*-
+
+# If not running interactively, don't do anything
+if [[ $- != *i* ]]; then
+ return
+fi
+
+
+# Don't put duplicate lines in the history. See bash(1) for more options
+# ... or force ignoredups and ignorespace
+HISTCONTROL=ignoredups:ignorespace
+# Append to the history file, don't overwrite it
+shopt -s histappend
+# For setting history length see HISTSIZE and HISTFILESIZE in bash(1)
+HISTSIZE=1000
+HISTFILESIZE=2000
+
+# Check the window size after each command and, if necessary, update the values of LINES and COLUMNS.
+shopt -s checkwinsize
+
+
+set -o physical
+alias cd='cd -L'
+
+
+
+if test -r ~/.config/bash/aliases; then
+ . ~/.config/bash/aliases
+fi
+
+if test -r /etc/bash_opt; then
+ . /etc/bash_opt
+fi
+
+~/.config/bash/bashrc_palette
+~/.config/bash/bashrc_prompt
+
+for __script in ~/.config/bash/bashrc.d/*; do
+ if test -r "${__script}"; then
+ . "${__script}"
+ fi
+done
+unset __script
+
+if test -r ~/.config/bash/"bashrc-$(hostname)"; then
+ . ~/.config/bash/"bashrc-$(hostname)"
+fi
+
+if test -r ~/work/.config/bash/bashrc; then
+ . ~/work/.config/bash/bashrc
+fi
+
+
+
+if test "$TERM" = linux; then
+ printf '\e[?8c'
+ if test -n "$PALETTE"; then
+ printf "$PALETTE"'\e[H\e[2J'
+ fi
+ palette-set `blackNcsColours`
+elif test "$TERM" = xterm; then
+ export TERM=xterm-256color
+fi
+featherweight-off
diff --git a/bash/bashrc_palette b/bash/bashrc_palette
new file mode 100644
index 0000000..8a4405a
--- /dev/null
+++ b/bash/bashrc_palette
@@ -0,0 +1,89 @@
+# DESCRIPTION: Palettes for the terminal
+
+# DESCRIPTION: Restore to the last selected palette
+# USAGE: palette-reset
+
+# DESCRIPTION: Store the last selected palette has that on set by <command>
+# USAGE: palette-set <command>
+
+# DESCRIPTION: The last choosen palette
+# VARIABLE: $PALETTE
+
+# Commands for setting the palette:
+# linuxColours The standard Linux VT palette
+# tangoColours The Tango palette
+# tangoidColours The Tango palette, but with black background
+# cobaltColours The Cobalt palette
+# yellowColours A palette with yellow background
+# redColours A palette with red background
+# ncsColours A palette based on NCS S 2050 with blue background
+# lightNcsColours A palette based on NCS S 2050 with lighter blue background
+# blackNcsColours A palette based on NCS S 2050 with black background
+
+
+__linux_c='\e]4;0;rgb:00/00/00\e\\\e]4;1;rgb:AA/00/00\e\\\e]4;2;rgb:00/AA/00\e\\\e]4;3;rgb:AA/55/00\e\\\e]4;4;rgb:00/00/AA\e\\\e]4;5;rgb:AA/00/AA\e\\\e]4;6;rgb:00/AA/AA\e\\\e]4;7;rgb:AA/AA/AA\e\\\e]4;8;rgb:55/55/55\e\\\e]4;9;rgb:FF/55/55\e\\\e]4;10;rgb:55/FF/55\e\\\e]4;11;rgb:FF/FF/55\e\\\e]4;12;rgb:55/55/FF\e\\\e]4;13;rgb:FF/55/FF\e\\\e]4;14;rgb:55/FF/FF\e\\\e]4;15;rgb:FF/FF/FF\e\\'
+
+__tango_c='\e]4;0;rgb:2E/34/36\e\\\e]4;1;rgb:CC/00/00\e\\\e]4;2;rgb:4E/9A/06\e\\\e]4;3;rgb:C4/A0/00\e\\\e]4;4;rgb:34/65/A4\e\\\e]4;5;rgb:75/50/7B\e\\\e]4;6;rgb:06/98/9A\e\\\e]4;7;rgb:D3/D7/CF\e\\\e]4;8;rgb:58/58/58\e\\\e]4;9;rgb:FF/55/55\e\\\e]4;10;rgb:55/FF/55\e\\\e]4;11;rgb:FF/FF/55\e\\\e]4;12;rgb:55/55/FF\e\\\e]4;13;rgb:FF/55/FF\e\\\e]4;14;rgb:55/FF/FF\e\\\e]4;15;rgb:FF/FF/FF\e\\'
+
+__tangoid_c='\e]4;0;rgb:00/00/00\e\\\e]4;1;rgb:CC/00/00\e\\\e]4;2;rgb:4E/9A/06\e\\\e]4;3;rgb:C4/A0/00\e\\\e]4;4;rgb:34/65/A4\e\\\e]4;5;rgb:75/50/7B\e\\\e]4;6;rgb:06/98/9A\e\\\e]4;7;rgb:D3/D7/CF\e\\\e]4;8;rgb:58/58/58\e\\\e]4;9;rgb:FF/55/55\e\\\e]4;10;rgb:55/FF/55\e\\\e]4;11;rgb:FF/FF/55\e\\\e]4;12;rgb:55/55/FF\e\\\e]4;13;rgb:FF/25/5FF\e\\\e]4;14;rgb:55/FF/FF\e\\\e]4;15;rgb:FF/FF/FF\e\\'
+
+__cobalt_c='\e]4;0;rgb:02/08/40\e\\\e]4;1;rgb:CC/00/00\e\\\e]4;2;rgb:4E/9A/06\e\\\e]4;3;rgb:C4/A0/00\e\\\e]4;4;rgb:34/657A4\e\\\e]4;5;rgb:75/50/7B\e\\\e]4;6;rgb:06/98/9A\e\\\e]4;7;rgb:D3/D7/CF\e\\\e]4;8;rgb:58/58/58\e\\\e]4;9;rgb:FF/55/55\e\\\e]4;10;rgb:55/FF/55\e\\\e]4;11;rgb:FF/FF/55\e\\\e]4;12;rgb:55/55/FF\e\\\e]4;13;rgb:FF/55/FF\e\\\e]4;14;rgb:55/FF/FF\e\\\e]4;15;rgb:FF/FF/FF\e\\'
+
+__yellow_c='\e]4;0;rgb:30/30/08\e\\\e]4;1;rgb:CC/00/00\e\\\e]4;2;rgb:4E/9A/06\e\\\e]4;3;rgb:C4/A0/00\e\\\e]4;4;rgb:34/65/A4\e\\\e]4;5;rgb:75/50/7B\e\\\e]4;6;rgb:06/98/9A\e\\\e]4;7;rgb:D3/D7/CF\e\\\e]4;8;rgb:58/58/58\e\\\e]4;9;rgb:FF/55/55\e\\\e]4;10;rgb:55/FF/55\e\\\e]4;11;rgb:FF/FF/55\e\\\e]4;12;rgb:55/55/FF\e\\\e]4;13;rgb:FF/55/FF\e\\\e]4;14;rgb:55/FF/FF\e\\\e]4;15;rgb:FF/FF/FF\e\\'
+
+__red_c='\e]4;0;rgb:30/00/00\e\\\e]4;1;rgb:CD/65/6C\e\\\e]4;2;rgb:32/A6/79\e\\\e]4;3;rgb:CC/AD/47\e\\\e]4;4;rgb:24/95/BE\e\\\e]4;5;rgb:A4/6E/B0\e\\\e]4;6;rgb:00/A0/9F\e\\\e]4;7;rgb:D3/D7/CF\e\\\e]4;8;rgb:55/57/53\e\\\e]4;9;rgb:EB/5E/6A\e\\\e]4;10;rgb:0E/C2/87\e\\\e]4;11;rgb:F2/CA/38\e\\\e]4;12;rgb:00/AC/E0\e\\\e]4;13;rgb:C4/73/D1\e\\\e]4;14;rgb:00/C3/C7\e\\\e]4;15;rgb:EE/EE/EE\e\\'
+
+__ncs_c='\e]4;0;rgb:02/08/40\e\\\e]4;1;rgb:CD/65/6C\e\\\e]4;2;rgb:32/A6/79\e\\\e]4;3;rgb:CC/AD/47\e\\\e]4;4;rgb:24/95/BE\e\\\e]4;5;rgb:A4/6E/B0\e\\\e]4;6;rgb:00/A0/9F\e\\\e]4;7;rgb:D3/D7/CF\e\\\e]4;8;rgb:55/57/53\e\\\e]4;9;rgb:EB/5E/6A\e\\\e]4;10;rgb:0E/C2/87\e\\\e]4;11;rgb:F2/CA/38\e\\\e]4;12;rgb:00/AC/E0\e\\\e]4;13;rgb:C4/73/D1\e\\\e]4;14;rgb:00/C3/C7\e\\\e]4;15;rgb:EE/EE/EE\e\\'
+
+__light_ncs_c='\e]4;0;rgb:0C/14/58\e\\\e]4;1;rgb:CD/65/6C\e\\\e]4;2;rgb:32/A6/79\e\\\e]4;3;rgb:CC/AD/47\e\\\e]4;4;rgb:24/95/BE\e\\\e]4;5;rgb:A4/6E/B0\e\\\e]4;6;rgb:00/A0/9F\e\\\e]4;7;rgb:D3/D7/CF\e\\\e]4;8;rgb:55/57/53\e\\\e]4;9;rgb:EB/5E/6A\e\\\e]4;10;rgb:0E/C2/87\e\\\e]4;11;rgb:F2/CA/38\e\\\e]4;12;rgb:00/AC/E0\e\\\e]4;13;rgb:C4/73/D1\e\\\e]4;14;rgb:00/C3/C7\e\\\e]4;15;rgb:EE/EE/EE\e\\'
+
+__black_ncs_c='\e]4;0;rgb:00/00/00\e\\\e]4;1;rgb:CD/65/6C\e\\\e]4;2;rgb:32/A6/79\e\\\e]4;3;rgb:CC/AD/47\e\\\e]4;4;rgb:24/95/BE\e\\\e]4;5;rgb:A4/6E/B0\e\\\e]4;6;rgb:00/A0/9F\e\\\e]4;7;rgb:D3/D7/CF\e\\\e]4;8;rgb:55/57/53\e\\\e]4;9;rgb:EB/5E/6A\e\\\e]4;10;rgb:0E/C2/87\e\\\e]4;11;rgb:F2/CA/38\e\\\e]4;12;rgb:00/AC/E0\e\\\e]4;13;rgb:C4/73/D1\e\\\e]4;14;rgb:00/C3/C7\e\\\e]4;15;rgb:EE/EE/EE\e\\'
+
+
+if [ "$TERM" = "linux" ]; then
+ __c () {
+ sed -e 's:;10;:A:g' -e 's:;11;:B:g' -e 's:;12;:C:g' -e 's:;13;:D:g' -e 's:;14;:E:g' -e 's:;15;:F:g' |
+ sed -e 's:]4:]P:g' -e 's:;::g' -e 's:rgb::g' -e 's:/::g' -e 's/://g' -e 's:\\e\\\\::g'
+ }
+ __linux_c="$(__c <<<"${__linux_c}")"
+ __tango_c="$(__c <<<"${__tango_c}")"
+ __tangoid_c="$(__c <<<"${__tangoid_c}")"
+ __cobalt_c="$(__c <<<"${__cobalt_c}")"
+ __yellow_c="$(__c <<<"${__yellow_c}")"
+ __red_c="$(__c <<<"${__red_c}")"
+ __ncs_c="$(__c <<<"${__ncs_c}")"
+ __light_ncs_c="$(__c <<<"${__light_ncs_c}")"
+ __black_ncs_c="$(__c <<<"${__black_ncs_c}")"
+fi
+
+alias linuxColours='echo -en "${__linux_c}"'
+alias tangoColours='echo -en "${__tango_c}"'
+alias tangoidColours='echo -en "${__tangoid_c}"'
+alias cobaltColours='echo -en "${__cobalt_c}"'
+alias yellowColours='echo -en "${__yellow_c}"'
+alias redColours='echo -en "${__red_c}"'
+alias ncsColours='echo -en "${__ncs_c}"'
+alias lightNcsColours='echo -en "${__light_ncs_c}"'
+alias blackNcsColours='echo -en "${__black_ncs_c}"'
+
+if [ "$USER" = 'root' ]; then
+ alias stdColours=redColours
+else
+ alias stdColours=blackNcsColours
+fi
+
+if [ "$COLORTERM" = '' ]; then
+ stdColours
+fi
+
+PALETTE=
+
+palette-set () {
+ PALETTE="$*"
+}
+
+palette-reset () {
+ printf '%s' "$PALETTE"
+}
+
+palette-set `stdColours`
diff --git a/bash/bashrc_prompt b/bash/bashrc_prompt
new file mode 100644
index 0000000..5463afb
--- /dev/null
+++ b/bash/bashrc_prompt
@@ -0,0 +1,413 @@
+#DESCRIPTION: A nicer default shell prompt line
+
+
+#DESCRIPTION: Use full block cursor Do not use full block cursor
+#USAGE block-on block-off
+
+#DESCRIPTION: Print username Do not print username Set colour of username
+#USAGE: username-on username-off username-colour <ansi-colour>
+
+#DESCRIPTION: Print hostname Do not print hostname Set colour of hostname
+#USAGE: hostname-on hostname-off hostname-colour <ansi-colour>
+
+#DESCRIPTION: Print IP address in place hostname
+#USAGE: hostname-ip
+
+#DESCRIPTION: Print terminal name Do not print terminal name Set colour of terminal name
+#USAGE: pts-on pts-off pts-colour <ansi-colour>
+
+#DESCRIPTION: Print git branch Do not print git branch Set colour of git branch
+#USAGE: git-on git-off git-colour <ansi-colour>
+
+#DESCRIPTION: Print directory Do not print directory Set colour of directory
+#USAGE: dir-on dir-off dir-colour <ansi-colour>
+
+#DESCRIPTION: Print directory tip Print absolute directory Print custom directory
+#USAGE: dir-short dir-full dir-text <text>
+
+#DESCRIPTION: Print current time Do not print current time Set colour of current time
+#USAGE: clock-on clock-off clock-colour <ansi-colour>
+
+#DESCRIPTION: Print battery status Do not print battery status Set colour of battery status
+#USAGE: battery-on battery-off battery-colour <ansi-colour>
+
+#DESCRIPTION: Print featherweight status Do not print featherweight status Set the used colour
+#USAGE featherweight-on featherweight-off featherweight-colour <ansi-colour>
+
+#DESCRIPTION: Set title on terminal Do not set title on terminal
+#USAGE title-on title-off
+
+#DESCRIPTION: Use two lines Use a single line
+#USAGE dual-on dual-off
+
+#DESCRIPTION: Set colour of error code
+#USAGE error-colour <ansi-colour>
+
+#DESCRIPTION: Set colour of dollar/hash sign
+#USAGE dollar-colour <ansi-colour>
+
+
+prompt_addons=()
+
+
+__prompt_block=""
+if [ "$TERM" = "linux" ]; then
+ __prompt_block="\033[?8c"
+fi
+block-on () {
+ __prompt_block="\033[?8c"
+ update-prompt
+}
+block-off () {
+ __prompt_block=""
+ update-prompt
+}
+
+
+__prompt_username="\u"
+username-on () {
+ __prompt_username="\u"
+ update-prompt
+}
+username-off () {
+ __prompt_username=""
+ update-prompt
+}
+
+
+__prompt_username_colour="94"
+if [ "$USER" = "root" ]; then
+ __prompt_username_colour="91"
+ if [ "$TERM" = "linux" ]; then
+ __prompt_username_colour="31;01"
+ fi
+elif [ "$TERM" = "linux" ]; then
+ __prompt_username_colour="34;01"
+fi
+username-colour () {
+ __prompt_username_colour="$*"
+ update-prompt
+}
+
+
+__prompt_hostname="1"
+hostname-on () {
+ __prompt_hostname="1"
+ update-prompt
+}
+hostname-ip () {
+ __prompt_hostname="$( (ifconfig | sed -n 's/^[\t ]*inet[\t ][\t ]*\([^\t ]*\).*$/\1/p' |
+ sed '/^127\.0\.0\.1$/d' ; echo 127.0.0.1) | sed 1q )"
+ update-prompt
+}
+hostname-off () {
+ __prompt_hostname="0"
+ update-prompt
+}
+
+
+__prompt_hostname_colour="34"
+hostname-colour () {
+ __prompt_hostname_colour="$*"
+ update-prompt
+}
+
+
+__prompt_pts="0"
+if [ "$TERM" = "linux" ]; then
+ __prompt_pts="1"
+fi
+pts-on () {
+ __prompt_pts="1"
+ update-prompt
+}
+pts-off () {
+ __prompt_pts="0"
+ update-prompt
+}
+
+
+__prompt_pts_colour="36"
+pts-colour () {
+ __prompt_pts_colour="$*"
+ update-prompt
+}
+
+
+__prompt_git="1"
+git-on () {
+ __prompt_git="1"
+ update-prompt
+}
+git-off () {
+ __prompt_git="0"
+ update-prompt
+}
+
+
+__prompt_git_colour="32"
+git-colour () {
+ __prompt_git_colour="$*"
+ update-prompt
+}
+
+
+__prompt_func_git () {
+ exec 2>/dev/null
+ if git status >&2; then
+ status="$(git status -s -b | head -n 1)"
+ if [ "$(echo "${status}" | cut -d ' ' -f 3)" = '[ahead' ]; then
+ echo "${status}" | cut -d ' ' -f 2
+ else
+ echo "${status}" | cut -d ' ' -f 2 | cut -d . -f 1
+ fi
+ fi
+}
+
+
+__prompt_dir="\w"
+dir-on () {
+ __prompt_dir="\w"
+ update-prompt
+}
+dir-short () {
+ __prompt_dir="\W"
+ update-prompt
+}
+dir-full () {
+ __prompt_dir='$(pwd)'
+ update-prompt
+}
+dir-text () {
+ __prompt_dir="$(sed -e 's:\\:\\\\:g' <<<"$*")"
+ update-prompt
+}
+dir-off () {
+ __prompt_dir=""
+ update-prompt
+}
+
+
+__prompt_dir_colour="35"
+dir-colour () {
+ __prompt_dir_colour="$*"
+ update-prompt
+}
+
+
+__prompt_clock="(\t)"
+clock-on () {
+ __prompt_clock="(\t)"
+ update-prompt
+}
+clock-off () {
+ __prompt_clock=""
+ update-prompt
+}
+
+
+__prompt_clock_colour="33"
+clock-colour () {
+ __prompt_clock_colour="$*"
+ update-prompt
+}
+
+
+__prompt_dual="\[\033[00m\]\n\[\033[1K\]"
+dual-on () {
+ __prompt_dual="\[\033[00m\]\n\[\033[1K\]"
+ update-prompt
+}
+dual-off () {
+ __prompt_dual=""
+ update-prompt
+}
+
+
+__prompt_dollar_colour="01;34"
+if [ "$USER" = "root" ]; then
+ __prompt_dollar_colour="01;31"
+fi
+dollar-colour () {
+ __prompt_dollar_colour="$*"
+ update-prompt
+}
+
+
+__prompt_error_colour="01;31"
+error-colour () {
+ __prompt_error_colour="$*"
+ update-prompt
+}
+
+
+__prompt_func_error () {
+ if [ "$1" = "0" ]; then
+ echo -n ""
+ else
+ echo -n "(error: $1) "
+ fi
+}
+
+
+__prompt_battery=""
+battery-on () {
+ __prompt_battery='$(__prompt_func_battery)'
+ update-prompt
+}
+battery-off () {
+ __prompt_battery=""
+ update-prompt
+}
+
+
+__prompt_battery_colour="33"
+battery-colour () {
+ __prompt_battery_colour="$*"
+ update-prompt
+}
+
+
+__prompt_func_battery () {
+ local __first=1
+ acpi --battery 2>/dev/null | while read info; do
+ if [ $__first = 1 ]; then
+ echo -n "(${info})"
+ __first=0
+ else
+ echo -n " (${info})"
+ fi
+ done
+}
+
+
+__prompt_featherweight='$(__prompt_func_featherweight)'
+featherweight-on () {
+ __prompt_featherweight='$(__prompt_func_featherweight)'
+ update-prompt
+}
+featherweight-off () {
+ __prompt_featherweight=''
+ update-prompt
+}
+
+
+__prompt_featherweight_colour="36"
+featherweight-colour () {
+ __prompt_featherweight_colour="$*"
+ update-prompt
+}
+
+
+__prompt_func_featherweight () {
+ local status
+ if [ -r ~/.var/lib/featherweight/status ]; then
+ status="$(cat ~/.var/lib/featherweight/status)"
+ if [ ! "${status}" = "0" ]; then
+ echo "(fw: ${status})"
+ fi
+ fi
+}
+
+
+__prompt_title=""
+case "$TERM" in
+ xterm*|rxvt*|Eterm|aterm|kterm|gnome*)
+ __prompt_title="\033]0;\u@\h: \w || $(tty)\a"
+ ;;
+esac
+title-on () {
+ __prompt_title="\033]0;\u@\h: \w || $(tty)\a"
+ update-prompt
+}
+title-off () {
+ __prompt_title=""
+ update-prompt
+}
+
+
+__screen_title=""
+case "$TERM" in
+ screen)
+ __screen_title="\033_\u@\h: \w || $(tty)\033\\"
+ ;;
+esac
+screen-title-on () {
+ __screen_title="\033_\u@\h: \w || $(tty)\033\\"
+ update-prompt
+}
+screen-title-off () {
+ __screen_title=""
+ update-prompt
+}
+
+
+update-prompt () {
+ local __invisible __addon
+ __invisible="\[${__prompt_title}${__screen_title}${__prompt_block}\033[00m\]"
+ PS1=""
+ if [ ! "${__prompt_username}" = "" ]; then
+ PS1="${PS1}\[\033[${__prompt_username_colour}m\]${__prompt_username}\[\033[00m\]"
+ fi
+ if [ "${__prompt_hostname}" = "1" ]; then
+ if [ ! "${PS1}" = "" ]; then
+ PS1="${PS1}@"
+ fi
+ PS1="${PS1}\[\033[${__prompt_hostname_colour}m\]\h\[\033[00m\]"
+ elif [ ! "${__prompt_hostname}" = "0" ]; then
+ if [ ! "${PS1}" = "" ]; then
+ PS1="${PS1}@"
+ fi
+ PS1="${PS1}\[\033[${__prompt_hostname_colour}m\]${__prompt_hostname}\[\033[00m\]"
+ fi
+ if [ "${__prompt_pts}" = "1" ]; then
+ if [ ! "${PS1}" = "" ]; then
+ PS1="${PS1}."
+ fi
+ PS1="${PS1}\[\033[${__prompt_pts_colour}m\]\l\[\033[00m\]"
+ fi
+ if [ "${__prompt_git}" = "1" ]; then
+ if [ ! "${PS1}" = "" ]; then
+ PS1="${PS1}"'$(git status 2>/dev/null >&2 && echo -n : || echo -n "")'
+ fi
+ PS1="${PS1}\[\033[${__prompt_git_colour}m\]"'$(__prompt_func_git)'"\[\033[00m\]"
+ fi
+ if [ ! "${__prompt_dir}" = "" ]; then
+ if [ ! "${PS1}" = "" ]; then
+ PS1="${PS1}: "
+ fi
+ PS1="${PS1}\[\033[${__prompt_dir_colour}m\]${__prompt_dir}\[\033[00m\]"
+ fi
+ if [ ! "${__prompt_clock}" = "" ]; then
+ if [ ! "${PS1}" = "" ]; then
+ PS1="${PS1} "
+ fi
+ PS1="${PS1}\[\033[${__prompt_clock_colour}m\]${__prompt_clock}\[\033[00m\]"
+ fi
+ if [ ! "${__prompt_battery}" = "" ]; then
+ if [ ! "${PS1}" = "" ]; then
+ PS1="${PS1} "
+ fi
+ PS1="${PS1}\[\033[${__prompt_battery_colour}m\]${__prompt_battery}\[\033[00m\]"
+ fi
+ if [ ! "${__prompt_featherweight}" = "" ]; then
+ if [ ! "${PS1}" = "" ]; then
+ PS1="${PS1} "
+ fi
+ PS1="${PS1}\[\033[${__prompt_featherweight_colour}m\]${__prompt_featherweight}\[\033[00m\]"
+ fi
+ __sh="\[\033[00m\033[${__prompt_dollar_colour}m\]\\$\[\033[00m\]"
+ __err="\[\033[${__prompt_error_colour}m\]"'$(__prompt_func_error $?)'"\[\033[00m\]"
+ for __addon in "${prompt_addons[@]}"; do
+ PS1="${PS1}$(${__addon})"
+ done
+ PS1="${__invisible}${__err}${PS1}${__prompt_dual}${__sh} "
+}
+
+
+update-prompt
+
+
+PS2='\[\e[01;31m\]> \[\e[00m\]'
+PS3='\[\e[01;31m\]> \[\e[00m\]'
+PS4='\[\e[01;31m\]+ \[\e[00m\]'
diff --git a/bash/logout b/bash/logout
new file mode 100644
index 0000000..ef22cbc
--- /dev/null
+++ b/bash/logout
@@ -0,0 +1,9 @@
+# -*- shell-script -*-
+
+if test -r ~/.config/bash/"logout-$(hostname)"; then
+ . ~/.config/bash/"logout-$(hostname)"
+fi
+
+if test -r ~/work/.config/bash/logout; then
+ . ~/work/.config/bash/logout
+fi
diff --git a/bash/profile b/bash/profile
new file mode 100644
index 0000000..096711e
--- /dev/null
+++ b/bash/profile
@@ -0,0 +1,17 @@
+# -*- shell-script -*-
+
+if test -r ~/.config/profile; then
+ . ~/.config/profile
+fi
+
+if test -r ~/.config/bash/"profile-$(hostname)"; then
+ . ~/.config/bash/"profile-$(hostname)"
+fi
+
+if test -r ~/work/.config/bash/profile; then
+ . ~/work/.config/bash/profile
+fi
+
+if test -r ~/.config/bash/bashrc; then
+ . ~/.config/bash/bashrc;
+fi