Skip to content
Snippets Groups Projects
Commit 9d5c851f authored by nimrod's avatar nimrod
Browse files

- Added optional error code and run duration to Bash' prompt.

- Set the history file location, should work across different shells.
- All exports are together in .bashrc.
- All Bash specifics are together in .bashrc.
parent 0a4caf2b
Branches
No related tags found
No related merge requests found
......@@ -2,16 +2,12 @@
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
export LANG=en_US.UTF8
export HISTCONTROL=ignoreboth:erasedups
export HISTSIZE=100000
export HISTFILESIZE=100000
export PROMPT_COMMAND="history -a; $PROMPT_COMMAND"
if [ -n "${BASH:-}" ]
then
shopt -s histappend
shopt -s checkwinsize
shopt -s cmdhist
export PROMPT_COMMAND="history -a"
[ -f /etc/bash_completion ] && . /etc/bash_completion
# shellcheck disable=SC1090
......@@ -32,6 +28,13 @@ if [ -x /usr/bin/dircolors ]; then
alias diff='diff --color=auto'
fi
export LANG=en_US.UTF8
export HISTFILE="$HOME/.history"
export HISTCONTROL=ignoreboth:erasedups
export HISTSIZE=100000
export HISTFILESIZE=100000
export PS0="\$(__prerun)"
export PS1="\$(__prompt)\u@\h:\w\$ "
export REPREPRO_BASE_DIR="$HOME/Documents/Shore/debian-repository"
export EDITOR=vim
export GOPATH="$HOME/Documents/Golang"
......@@ -55,6 +58,7 @@ export ANSIBLE_CALLBACK_WHITELIST=profile_tasks
export LYNX_SAVE_SPACE="$HOME/Downloads"
export LYNX_TEMP_SPACE="$HOME/.cache/lynx"
export VAGRANT_DEFAULT_PROVIDER="virtualbox"
alias ll='ls -lha'
alias la='ls -A'
alias l='ls -CF'
......@@ -183,5 +187,31 @@ match_ssl_pair () {
return "$exitcode"
}
__run_duration () {
# Assumes that $HOME/.prerun.$$ exists.
local endtime starttime
endtime="$(date +%s)"
starttime="$(cat "$HOME/.prerun.$$")"
rm "$HOME/.prerun.$$"
echo "$(( endtime - starttime ))"
}
__prerun () {
date +%s > "$HOME/.prerun.$$"
}
__prompt () {
local exitstatus="$?"
local runduration prompt
#nocolor="\033[0m"
#red="\033[31;1m"
#yellow="\033[33;1m"
prompt=""
[ "$exitstatus" = "0" ] || prompt="[Exit status: $exitstatus] $prompt"
[ ! -f "$HOME/.prerun.$$" ] || runduration="$(__run_duration)"
[ "${runduration:-0}" -lt "10" ] || prompt="[Run duration: $runduration] $prompt"
echo "$prompt"
}
# shellcheck disable=SC1090
. "$HOME/Documents/Shore/bundle_certs/bundle_certs"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment