FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux General Discussion

 
 
LinkBack Thread Tools
 
Old 06-30-2010, 09:47 PM
Victor Lowther
 
Default Tighten up the console size finding code a bit.

---
functions | 30 +++++++++++++-----------------
1 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/functions b/functions
index 023de35..a9acf6f 100644
--- a/functions
+++ b/functions
@@ -5,26 +5,21 @@
# width:

STAT_COL=80
-if [ ! -t 1 ]; then
- USECOLOR=""
-
-# stty will fail when stdin isn't a terminal
-elif [ -t 0 ]; then
- STAT_COL="$(/bin/stty size)"
- # stty gives "rows cols"; strip the rows number, we just want columns
- STAT_COL="${STAT_COL##* }"
-
-else
+if [[ ! -t 1 ]]; then
+ USECOLOR=""
+elif [[ -t 0 ]]; then
+ # stty will fail when stdin isn't a terminal
+ STAT_COL="$(/bin/stty size)"
+ # stty gives "rows cols"; strip the rows number, we just want columns
+ STAT_COL="${STAT_COL##* }"
+elif /bin/tput cols &>/dev/null; then
# is /usr/share/terminfo already mounted, and TERM recognized?
- /bin/tput cols &>/dev/null
- if [ $? -eq 0 ]; then
STAT_COL=$(/bin/tput cols)
- fi
fi
-if [ "0$STAT_COL" -eq 0 ]; then
- # if output was 0 (serial console), set default width to 80
- STAT_COL=80
- USECOLOR=""
+if ((STAT_COL==0)); then
+ # if output was 0 (serial console), set default width to 80
+ STAT_COL=80
+ USECOLOR=""
fi

# we use 13 characters for our own stuff
@@ -54,6 +49,7 @@ unset TZ
# colors:
if [ "$USECOLOR" = "YES" -o "$USECOLOR" = "yes" ]; then
C_MAIN="33[1;37;40m" # main text
+
C_OTHER="33[1;34;40m" # prefix & brackets
C_SEPARATOR="33[1;30;40m" # separator

--
1.7.1
 

Thread Tools




All times are GMT. The time now is 10:38 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org