Colours for PS2 and PS4.
authorIain Patterson <me@iain.cx>
Tue, 24 Jun 2014 12:52:56 +0000 (13:52 +0100)
committerIain Patterson <me@iain.cx>
Mon, 30 Jun 2014 16:04:38 +0000 (12:04 -0400)
.profile.d/ps2.bashrc [new file with mode: 0644]
.profile.d/ps4.bashrc [new file with mode: 0644]

diff --git a/.profile.d/ps2.bashrc b/.profile.d/ps2.bashrc
new file mode 100644 (file)
index 0000000..73ee0ad
--- /dev/null
@@ -0,0 +1,32 @@
+#!bash Coloured prompts.
+# profile-required: ps1.bashrc
+
+case $(tput colors) in
+  256)
+    PS2_COLOUR1="0;38;5;22"
+    PS2_COLOUR2="0;38;5;28"
+    PS2_COLOUR3="0;38;5;34"
+    PS2_COLOUR4="0;38;5;40"
+  ;;
+
+  88)
+    PS2_COLOUR1="0;38;5;20"
+    PS2_COLOUR2="0;38;5;24"
+    PS2_COLOUR3="0;38;5;24"
+    PS2_COLOUR4="0;38;5;28"
+  ;;
+
+  *)
+    PS2_COLOUR1="0;32"
+    PS2_COLOUR2="0;32"
+    PS2_COLOUR3="1;32"
+    PS2_COLOUR4="1;32"
+  ;;
+esac
+
+function __ps2() {
+  PS2='\[\033[0m\]\[\033[$(__ps1_colour_escape 0 $PS2_COLOUR1)m\]>\[\033[$(__ps1_colour_escape 0 $PS2_COLOUR2)m\]>\[\033[$(__ps1_colour_escape 0 $PS2_COLOUR3)m\]>\[\033[$(__ps1_colour_escape 0 $PS2_COLOUR4)m\]> \[\033[0m\]'
+  return 0
+}
+
+__ps2
diff --git a/.profile.d/ps4.bashrc b/.profile.d/ps4.bashrc
new file mode 100644 (file)
index 0000000..3746ac9
--- /dev/null
@@ -0,0 +1,26 @@
+#!bash Coloured prompts.
+# profile-required: ps1.bashrc
+
+case $(tput colors) in
+  256)
+    PS4_COLOUR1="0;38;5;20"
+    PS4_COLOUR2="0;38;5;26"
+  ;;
+
+  88)
+    PS4_COLOUR1="0;38;5;19"
+    PS4_COLOUR2="0;38;5;23"
+  ;;
+
+  *)
+    PS4_COLOUR1="0;36"
+    PS4_COLOUR2="1;36"
+  ;;
+esac
+
+function __ps4() {
+  PS4='\[\033[0m\]\[\033[$(__ps1_colour_escape 0 $PS4_COLOUR1)m\][\[\033[$(__ps1_colour_escape 0 $PS4_COLOUR2)m\]${0##*/}:$LINENO\[\033[$(__ps1_colour_escape 0 $PS4_COLOUR1)m\]] \[\033[0m\]'
+  return 0
+}
+
+__ps4