Added fallback to "stty" if "tput" is missing.
authorOleksandr Gavenko <gavenkoa@gmail.com>
Sun, 30 Dec 2018 12:30:21 +0200
changeset 916 6abe6497819a
parent 915 691db6af02e4
child 917 71ffdacfbc57
Added fallback to "stty" if "tput" is missing.
.bashrc
--- a/.bashrc	Sun Dec 30 12:26:48 2018 +0200
+++ b/.bashrc	Sun Dec 30 12:30:21 2018 +0200
@@ -14,7 +14,11 @@
 
 _my_ruler_handler() {
   local ruler='================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================'
-  local size=`tput cols`
+  if [[ -x /usr/bin/tput ]]; then
+    local size=`/usr/bin/tput cols`
+  else
+    local size=`/usr/bin/stty size | { read x y; echo $y; }`
+  fi
   ruler=${ruler:0:${size}}
   _my_ruler=$ruler
 }