aboutsummaryrefslogtreecommitdiff
path: root/home/.bashrc
diff options
context:
space:
mode:
Diffstat (limited to 'home/.bashrc')
-rw-r--r--home/.bashrc83
1 files changed, 82 insertions, 1 deletions
diff --git a/home/.bashrc b/home/.bashrc
index 786f06d..d4e96d3 100644
--- a/home/.bashrc
+++ b/home/.bashrc
@@ -1,7 +1,88 @@
1# ~/.bashrc 1# dotfiles/home/.bashrc -> /home/$USER/.bashrc
2# Author: Mountain Man 2# Author: Mountain Man
3 3
4
4# Test for an interactive shell. 5# Test for an interactive shell.
5if [[ $- != *i* ]] ; then 6if [[ $- != *i* ]] ; then
6 return 7 return
7fi 8fi
9
10
11##########################################################################
12# PS1 - Primary prompt displayed before each command
13####################################################
14# The PS1 prompt is constructed piece-by-piece by concatenating each
15# component to the previous component. Parts of the prompt are colored
16# conditionally based on what kind of user is logged in.
17#
18# Breakdown of PS1 components:
19# [TTY#] [DATE TIME] [USER HOST] [DIR] >
20#
21# Example of what the prompt should look like:
22# [1] [2023-03-28 16:02:55] [user host] [/etc/portage] >
23##########################################################################
24
25# Set colors for easy reading
26PS1_COLOR_RESET="\[\e[0m\]"
27PS1_COLOR_GREY="\[\e[90m\]"
28PS1_COLOR_RED="\[\e[91m\]"
29PS1_COLOR_YELLOW="\[\e[33m\]"
30PS1_COLOR_BLUE="\[\e[94m\]"
31PS1_COLOR_CYAN="\[\e[96m\]"
32
33if [[ "$(id -u)" == 0 ]]; then # if root
34 PS1_COLOR_MAIN=$PS1_COLOR_RED # set main color red
35elif [[ "$USER" == *"-dev" ]]; then # if -dev account
36 PS1_COLOR_MAIN=$PS1_COLOR_YELLOW # set main color yellow
37else # all other accounts
38 PS1_COLOR_MAIN=$PS1_COLOR_GREY # set main color grey
39fi
40
41# Start with a blank PS1 prompt
42PS1=""
43
44# [TTY#] [DATE TIME]
45PS1+=$PS1_COLOR_MAIN
46TTY_NUM=$(ps -p $$ -o tty= | tr -dc '0-9')
47PS1+="[$TTY_NUM] [\D{%F} \t] "
48PS1+=$PS1_COLOR_RESET
49
50# [SSH USER@HOST]
51PS1+=$PS1_COLOR_MAIN
52if [[ "$SSH_TTY" == "/dev/pts"* ]]; then # if this is SSH session
53 PS1+="[SSH " # add "[SSH "
54else
55 PS1+="["
56fi
57PS1+=$PS1_COLOR_RESET
58
59PS1+=$PS1_COLOR_CYAN
60PS1+="\u"
61PS1+=$PS1_COLOR_RESET
62
63PS1+=$PS1_COLOR_GREY
64PS1+="@"
65PS1+=$PS1_COLOR_RESET
66
67PS1+=$PS1_COLOR_BLUE
68PS1+="\h"
69PS1+=$PS1_COLOR_RESET
70
71PS1+=$PS1_COLOR_MAIN
72PS1+="] "
73PS1+=$PS1_COLOR_RESET
74
75# [DIR] >
76PS1+=$PS1_COLOR_MAIN
77PS1+="["
78PS1+=$PS1_COLOR_RESET
79
80PS1+=$PS1_COLOR_CYAN
81PS1+="\w"
82PS1+=$PS1_COLOR_RESET
83
84PS1+=$PS1_COLOR_MAIN
85PS1+="] >"
86PS1+=$PS1_COLOR_RESET
87
88##########################################################################