aboutsummaryrefslogtreecommitdiff
path: root/.bashrc
diff options
context:
space:
mode:
authorRaúl Benencia <rul@kalgan.cc>2019-06-24 00:00:15 -0700
committerRaúl Benencia <rul@kalgan.cc>2019-06-24 00:01:34 -0700
commit88fd5bed96899f99f425773f439852b4e690510c (patch)
tree9c94be1fd6a7611a53aef952e23cb714787ef249 /.bashrc
parent284c8327c95bb0c71b111ebf95723a35a478295c (diff)
Add .bashrc and related
Diffstat (limited to '.bashrc')
-rw-r--r--.bashrc109
1 files changed, 109 insertions, 0 deletions
diff --git a/.bashrc b/.bashrc
new file mode 100644
index 0000000..b5907f1
--- /dev/null
+++ b/.bashrc
@@ -0,0 +1,109 @@
+# Debian packages: fzf
+
+# If not running interactively, don't do anything else
+[ -z "$PS1" ] && return
+
+if [ -f $HOME/.environment ]; then
+ . $HOME/.environment
+fi
+
+eval `dircolors 2>/dev/null`
+
+# don't put duplicate lines in the history
+export HISTCONTROL=$HISTCONTROL${HISTCONTROL+,}ignoredups
+
+# append to the history file, don't overwrite it
+shopt -s histappend
+
+# store multi-line commands in history
+shopt -s cmdhist
+
+# this breaks eg "bts show #nnnnnn"
+shopt -u interactive_comments
+
+# check the window size after each command and, if necessary,
+# update the values of LINES and COLUMNS.
+shopt -s checkwinsize
+
+# Name directory to change to it.
+shopt -s autocd
+
+# Disable XOFF, for f*** sake
+stty -ixon
+
+# enable completion
+if [ -f /etc/bash_completion ]; then
+ . /etc/bash_completion
+fi
+
+# enable fzf completion if available
+if [ -f /usr/share/bash-completion/completions/fzf ]; then
+ . /usr/share/bash-completion/completions/fzf
+fi
+
+if [ -f /usr/share/doc/fzf/examples/key-bindings.bash ]; then
+ . /usr/share/doc/fzf/examples/key-bindings.bash
+fi
+
+# enable local completion
+if [ -d ~/.bash_completion.d/ ]; then
+ for f in $(find ~/.bash_completion.d/ -type f); do
+ . $f
+ done
+fi
+
+# aliases
+if [ -e ~/.alias.d/ ]; then
+ for e in $(find ~/.alias.d/ -type f); do
+ . $e
+ done
+fi
+
+umask 022
+
+update_title () {
+ printf "\e]0;$USER@$HOSTNAME: %s\a" "$1"
+}
+
+# Update title before executing a command: set it to the full command
+show_command () {
+ this_command="`history 1`"
+ update_title "${this_command/+([ ])+([0-9])+([ ])/}"
+}
+
+# Things to do before displaying the command prompt, including printing
+# nonzero exit status of the last run command, and setting the git branch.
+prompt_command_notitle () {
+ local code="$?"
+ if [ "$code" -ne 0 ]; then
+ echo "- exit $code"
+ fi
+
+ local fullbranch="$(cat .git/HEAD 2>/dev/null)"
+ if [ "$fullbranch" = "" ]; then
+ local fullbranch="$(git symbolic-ref HEAD 2>/dev/null)"
+ fi
+ local branch="${fullbranch##*/}"
+ vcsinfo="${branch:+#$branch}"
+}
+
+prompt_command () {
+ prompt_command_notitle
+ update_title
+}
+
+PS1='\u@\h:\w$vcsinfo> '
+
+case "$TERM" in
+xterm*|rxvt*|screen)
+ PS1="\[\e]0;\u@\h:\w\a\]$PS1"
+ trap show_command DEBUG
+ PROMPT_COMMAND=prompt_command
+ ;;
+*)
+ PROMPT_COMMAND=prompt_command_notitle
+ ;;
+esac
+
+export HISTFILESIZE=
+export HISTSIZE=
nihil fit ex nihilo