Browse code

bashrc - v1.11 - Add sty-updater function

Fred authored on17/08/2015 20:57:10
Showing1 changed files
... ...
@@ -1,8 +1,8 @@
1 1
 # Title: .bashrc
2 2
 # Author: Frédéric CHEVALIER <f15.chevalier@gmail.com>
3
-# Version: 1.10
3
+# Version: 1.11
4 4
 # Created in: 2012-05-26
5
-# Modified in: 2015-04-19
5
+# Modified in: 2015-08-17
6 6
 
7 7
 
8 8
 
... ...
@@ -19,7 +19,8 @@
19 19
 # Versions #
20 20
 #==========#
21 21
 
22
-# v.1.10 - 2015-04-19: one archive format added to the extract function / less behaviour improved / alias updated
22
+# v1.11 - 2015-08-17: sty-updater function added
23
+# v1.10 - 2015-04-19: one archive format added to the extract function / less behaviour improved / alias updated
23 24
 # v1.9 - 2014-10-18: value of TERM variable determined by case statement => this fix 256 color terminal problem / improvement of color capability detection / alias added
24 25
 # v1.8 - 2014-10-14: HISTIGNORE correction and adding / start_agent function output improved
25 26
 # v1.7 - 2014-09-25: start_agent function improved
... ...
@@ -387,6 +388,26 @@ function start_agent {
387 388
 }
388 389
 
389 390
 
391
+# STY updater
392
+# Usage: reset the STY value after change in screen session name
393
+function sty-updater {
394
+    # Check for STY presence
395
+    if [[ -z "$STY" ]]
396
+    then
397
+        echo "No STY present."
398
+    else
399
+        # Get the current STY value
400
+        old_sty=$STY
401
+
402
+        # Update STY with the new value
403
+        export STY=$(screen -list | sed "s/^\t//g" | grep $(echo $STY | cut -d "." -f 1) | cut -f 1)
404
+
405
+        # Info message
406
+        echo -e "The STY value has been updated:\n\t- old value: $old_sty\n\t- new value: $STY"
407
+    fi
408
+}
409
+
410
+
390 411
 
391 412
 #================================================#
392 413
 # User specific environment and startup programs #