aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.bash_profile9
-rw-r--r--.bashrc88
-rw-r--r--.config/shell/env5
-rw-r--r--.config/shell/init6
-rw-r--r--.config/shell/sources9
-rwxr-xr-x.zshrc3
6 files changed, 111 insertions, 9 deletions
diff --git a/.bash_profile b/.bash_profile
new file mode 100644
index 0000000..577f0c6
--- /dev/null
+++ b/.bash_profile
@@ -0,0 +1,9 @@
+#! /usr/bin/env bash
+
+#
+# It looks like logging in through a TTY doesn't load ~/.bashrc, but it does
+# load this particular file. So, to work around it, this file will load
+# ~/.bashrc anyway!
+#
+
+. $HOME/.bashrc
diff --git a/.bashrc b/.bashrc
index b289417..e6dd4cd 100644
--- a/.bashrc
+++ b/.bashrc
@@ -1,2 +1,88 @@
+[ $DEBUG_DOTFILES ] && echo "Loading .bashrc"
-complete -C /usr/bin/terraform terraform
+# Load initialization
+[ $DEBUG_DOTFILES ] && echo " Loading ~/.config/shell/init"
+source ~/.config/shell/init
+
+# Load the sources file, which in turn will source more functionality
+[ $DEBUG_DOTFILES ] && echo " Loading ~/.config/shell/sources"
+source ~/.config/shell/sources
+
+# Set vi mode
+[ $DEBUG_DOTFILES ] && echo " Setting vi-mode"
+set -o vi
+
+# Bind some emacs-style bindings in insert mode
+bind -m vi-insert "\C-a":beginning-of-line
+bind -m vi-insert "\C-b":backward-char
+bind -m vi-insert "\C-e":end-of-line
+bind -m vi-insert "\C-f":forward-char
+bind -m vi-insert "\C-k":kill-line
+bind -m vi-insert "\C-n":history-search-forward
+bind -m vi-insert "\C-p":history-search-backward
+bind -m vi-insert "\C-u":kill-region
+bind -m vi-insert "\C-y":yank
+
+# Configure Bash options
+[ $DEBUG_DOTFILES ] && echo " Setting autocompletions"
+shopt -s histappend
+
+# Set up the prompt
+[ $DEBUG_DOTFILES ] && echo " Setting PS1"
+PROMPT_COMMAND=__precmd
+
+__precmd()
+{
+ # Record exit code of previous command immediately
+ local previous_exit=$?
+
+ # Colors in the Bash prompt should be wrapped in \001 and \002,
+ # (RL_PROMPT_START_INGORE and RL_PROMPT_END_IGNORE) in order to avoid
+ # wrapping issues later in life. It is also *very* important to wrap
+ # things in double quotes for the PS1 coloring to be applied correctly!
+
+ # Set the username, hostname and path
+ PS1="\001$SHELLC_F_GREEN\002\u\001$SHELLC_RESET_COLOR_F\002"
+ PS1+="\001$SHELLC_F_LIGHTGRAY\002@\001$SHELLC_RESET_COLOR_F\002"
+ PS1+="\001$SHELLC_F_MAGENTA\002\H\001$SHELLC_RESET_COLOR_F\002"
+ PS1+="\001$SHELLC_F_LIGHTGRAY\002:\001$SHELLC_RESET_COLOR_F\002"
+ PS1+="\001$SHELLC_F_BLUE\002\w\001$SHELLC_RESET_COLOR_F\002"
+
+ # Add git status
+ if git rev-parse --is-inside-work-tree &> /dev/null
+ then
+ PS1+="\001$SHELLC_F_LIGHTGRAY\002·\001$SHELLC_RESET_COLOR_F\002"
+
+ # Set coloring of the branch name
+ if [[ "$(git status -uno --porcelain 2> /dev/null)" == "" ]]
+ then
+ PS1+="\001$SHELLC_F_GREEN\002"
+ else
+ PS1+="\001$SHELLC_F_YELLOW\002"
+ fi
+
+ # Get the branch name
+ local git_branch_name=$(git rev-parse --abbrev-ref @)
+
+ if [[ "$git_branch_name" == "HEAD" ]]
+ then
+ git_branch_name=$(git rev-parse --short HEAD 2> /dev/null)
+ fi
+
+ # Set the prompt
+ PS1+="$git_branch_name\001$SHELLC_RESET_COLOR_F\002"
+ fi
+
+ # Add the exit code of the previous command
+ PS1+=" "
+
+ if [[ $previous_exit -ne 0 ]]
+ then
+ PS1+="\001$SHELLC_F_RED\002"
+ fi
+
+ PS1+="$(printf "%03i" "$previous_exit")\001$SHELLC_RESET_COLOR_F\002"
+
+ # Final prompt character
+ PS1+=" \001$SHELLC_F_LIGHTGRAY\002»\001$SHELLC_RESET_FULL\002 \001$CURSOR_STYLE\002"
+}
diff --git a/.config/shell/env b/.config/shell/env
index 05505a8..b04d6b9 100644
--- a/.config/shell/env
+++ b/.config/shell/env
@@ -65,16 +65,13 @@ export QT_STYLE_OVERRIDE=GTK+
# Set tabsize in the TTY
#setterm -regtabs 4
-tabs -4 > /dev/null
+tabs -8 > /dev/null
# note to self: remove when rtorrent becomes sane or gets replaced
# double note to self: enable whenever you consider using rtorrent again
#stty start undef
#stty stop undef
-# enable interactive comments in zsh
-set -k
-
### setting up the tty
# alter the colors
echo -en "\e]P0000000" #black
diff --git a/.config/shell/init b/.config/shell/init
index 379d889..717e0c9 100644
--- a/.config/shell/init
+++ b/.config/shell/init
@@ -1,8 +1,8 @@
#! /usr/bin/env sh
+export SHORTSHELL=$(ps -p $$ | tail -n 1 | awk '{ print $NF }')
+
if [ -z "${SHELLSTORE}" ]
then
- SHELLSTORE=$(mktemp -d -t "shellstore_XXXXX")
-
- export SHELLSTORE
+ export SHELLSTORE=$(mktemp -d -t "shellstore_XXXXX")
fi
diff --git a/.config/shell/sources b/.config/shell/sources
index 5573d62..aa3e273 100644
--- a/.config/shell/sources
+++ b/.config/shell/sources
@@ -33,6 +33,13 @@ PATH="${PATH}:/usr/local/sbin"
PATH="${PATH}:/usr/games/bin"
PATH="${PATH}:/opt/bin"
+# Load color definitions if they exist
+if [ -f "$HOME/.config/shell/colors/$SHORTSHELL" ]
+then
+ [ "$DEBUG_DOTFILES" ] && printf " Loading color definitions\n"
+ . "$HOME/.config/shell/colors/$SHORTSHELL"
+fi
+
# Nix package manager
if [ -f "$HOME/.nix-profile/etc/profile.d/nix.sh" ]
then
@@ -67,7 +74,7 @@ then
if [ -d "$GEMDIR" ]
then
- [ "$DEBUG_DOTFILES" ] && echo "Extending PATH with $GEMDIR"
+ [ "$DEBUG_DOTFILES" ] && echo " Extending PATH with $GEMDIR"
PATH="$GEMDIR:$PATH"
fi
fi
diff --git a/.zshrc b/.zshrc
index 841ebcb..0a5c687 100755
--- a/.zshrc
+++ b/.zshrc
@@ -50,6 +50,9 @@ bindkey -M vicmd "gg" zle-move-to-buffer-beginning
[ $DEBUG_DOTFILES ] && echo " Setting autocompletions"
zstyle :compinstall filename '/home/tyil/.zshrc'
zstyle ':completion:*' menu select
+
+# Enable comments in interactive zsh
+set -k
# }}}
function precmd() # {{{