aboutsummaryrefslogtreecommitdiff
path: root/.bashrc
diff options
context:
space:
mode:
authortdro <tdro@users.noreply.github.com>2020-01-10 08:33:54 -0500
committertdro <tdro@users.noreply.github.com>2020-01-10 08:33:54 -0500
commita282983b7ae1077252ccc5e922624c94f7a4f5dd (patch)
tree1b344e0f4e7d7d599e102692d82c999034bc8e2e /.bashrc
parentbc31a73292429545e6d3d81fb6d78cbe60454f8f (diff)
downloaddotfiles-a282983b7ae1077252ccc5e922624c94f7a4f5dd.tar.gz
dotfiles-a282983b7ae1077252ccc5e922624c94f7a4f5dd.tar.bz2
dotfiles-a282983b7ae1077252ccc5e922624c94f7a4f5dd.zip
.bashrc: Check if root on PS1
Diffstat (limited to '.bashrc')
-rw-r--r--.bashrc23
1 files changed, 12 insertions, 11 deletions
diff --git a/.bashrc b/.bashrc
index 0c9b5e6..a4a7df8 100644
--- a/.bashrc
+++ b/.bashrc
@@ -1,20 +1,27 @@
#!/bin/bash
-# If not running interactively, don't do anything
+# bail if not interactive
[[ $- != *i* ]] && return
+# set prompt
+[[ "$EUID" -ne 0 ]] && PS1='\[\e[0;34m\]\W \$\[\e[0m\] '
+[[ "$EUID" -eq 0 ]] && PS1='\[\e[1;31m\]\W \$\[\e[0m\] '
+
# cd using directory name
shopt -s autocd;
+# append bash history entries
+shopt -s histappend;
+
+# bash history one command per line
+shopt -s cmdhist;
+
# disable ctrl+s
stty stop '';
stty start '';
stty -ixon;
stty -ixoff;
-# set prompt statement
-PS1='\[\e[0;34m\]\W \$\[\e[0m\] '
-
# set virtual console colors
if [ "$TERM" = "linux" ]; then
echo -en "\e]P0111111" #black [background]
@@ -50,7 +57,7 @@ man() {
# ssh bash prompt color change
if [ -n "$SSH_CLIENT" ]; then
- export PS1='\[\e[0;32m\][ \W ] \$\[\e[0m\] '
+ export PS1='\[\e[1;32m\]\W \$\[\e[0m\] '
fi
# disable less history
@@ -61,12 +68,6 @@ export HISTSIZE=
export HISTFILESIZE=
export HISTCONTROL=ignoredups:erasedups
-# append bash history entries
-shopt -s histappend;
-
-# bash history one command per line
-shopt -s cmdhist;
-
# prompt command runs on every command
export PROMPT_COMMAND="cd .; history -a"