commit 80237512df05dcfc1bb92da9d4105ca0574534e2
parent 0299a0be92bbeac30f9f02f573848ee8896c0cb3
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date: Thu, 23 May 2019 21:58:55 +0200
Clean up .bashrc and adapt most of zsh prompt functionality
Diffstat:
M | .bashrc | | | 57 | ++++++++++++++++----------------------------------------- |
1 file changed, 16 insertions(+), 41 deletions(-)
diff --git a/.bashrc b/.bashrc
@@ -3,8 +3,7 @@
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
-# don't put duplicate lines in the history. See bash(1) for more options
-# ... or force ignoredups and ignorespace
+# don't put duplicate lines in the history, and ignore lines with leading space
HISTCONTROL=ignoredups:ignorespace
# append to the history file, don't overwrite it
@@ -14,53 +13,29 @@ shopt -s histappend
HISTSIZE=10000
HISTFILESIZE=20000
-_has() {
- return $( type -v "$1" &> /dev/null )
-}
-
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
-# make less more friendly for non-text input files, see lesspipe(1)
-[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
-
export CLICOLOR=1
export HISTTIMEFORMAT='%F %T '
-export EDITOR=vim
-GPG_TTY=$(tty)
-export GPG_TTY
-
-. ~/.commands.sh
-# set a fancy prompt (non-color, unless we know we "want" color)
-case "$TERM" in
- xterm-color) color_prompt=yes;;
-esac
+# shellcheck source=/home/ad/.commands.sh
+. ~/.commands.sh # SC1019
-# uncomment for a colored prompt, if the terminal has the capability; turned
-# off by default to not distract the user: the focus in a terminal window
-# should be on the output of commands, not on the prompt
-force_color_prompt=yes
-
-if [ -n "$force_color_prompt" ]; then
- if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
- # We have color support; assume it's compliant with Ecma-48
- # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
- # a case would tend to support setf rather than setaf.)
- color_prompt=yes
- else
- color_prompt=
- fi
-fi
-
-if [ "$color_prompt" = yes ]; then
- PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;36m\]\w\[\033[00m\]\$ '
-else
- PS1='\u@\h:\w\$ '
-fi
-unset color_prompt force_color_prompt
+right_prompt() {
+ rprompt=" $PWD"
+ [[ $rprompt/ = " $HOME"/* ]] && rprompt=\~${rprompt# $HOME}
+ [ ! "$USER" = "ad" ] && rprompt+=" \u"
+ [ ! "$HOSTNAME" = "idkfa" ] && rprompt+=" \h"
+ printf "%*s" $COLUMNS "$rprompt"
+}
+set_prompt() {
+ PS1="\n\[$(tput sc; right_prompt; tput rc)\]\$ "
+}
+# function to call before PS1 is displayed
+PROMPT_COMMAND=set_prompt
-# shellcheck source=/Users/ad/.fzf.bash
+# shellcheck source=/home/ad/.fzf.bash
[ -f ~/.fzf.bash ] && source ~/.fzf.bash