[projects/setup] Added shrc.c snippets to enable 256 colors terminals (based on fedora)

baggins baggins at pld-linux.org
Sun Feb 9 20:16:13 CET 2014


commit 56e0bb15596f157caf70464b2ebed1300878ca58
Author: Jan Rękorajski <baggins at pld-linux.org>
Date:   Sun Feb 9 20:11:10 2014 +0100

    Added shrc.c snippets to enable 256 colors terminals (based on fedora)

 Makefile               |  5 ++++-
 etc/.cvsignore         |  2 --
 etc/shrc.d/256term.csh | 28 ++++++++++++++++++++++++++++
 etc/shrc.d/256term.sh  | 32 ++++++++++++++++++++++++++++++++
 4 files changed, 64 insertions(+), 3 deletions(-)
---
diff --git a/Makefile b/Makefile
index 01ee644..0af8ae5 100644
--- a/Makefile
+++ b/Makefile
@@ -22,6 +22,7 @@ ETC_FILES	= filesystems fstab group host.conf hosts motd \
 PROFILE_FILES	= tmp-dir.csh tmp-dir.sh
 ENV_FILES	= EDITOR HISTFILESIZE HOME_ETC MAILCHECK MAILPATH \
 	    NNTPSERVER ORGANIZATION TMOUT VISUAL
+SHRC_FILES	= 256term.csh 256term.sh
 
 SOURCES		= joinpasswd.c update-fstab.c postshell.c delpasswd.c
 CLEAN		= $(BIN_FILES) *.o core *.tar.gz *.tar.bz2 *~ *.swp
@@ -46,12 +47,14 @@ install:
 	$(INSTALL) -d $(DESTDIR)/$(SBINDIR)
 	$(INSTALL) -d $(DESTDIR)/$(ETCDIR)
 	$(INSTALL) -d $(DESTDIR)/$(PROFILEDIR)
-	$(INSTALL) -d  $(DESTDIR)/$(ENVDIR)
+	$(INSTALL) -d $(DESTDIR)/$(ENVDIR)
+	$(INSTALL) -d $(DESTDIR)/$(SHRCDIR)
 	$(INSTALL) $(BIN_FILES) $(DESTDIR)/$(SBINDIR)
 	cd etc; $(INSTALL) $(ETC_FILES) $(DESTDIR)/$(ETCDIR)
 	ln -sf /proc/self/mounts $(DESTDIR)/$(ETCDIR)/mtab
 	cd etc/profile.d; $(INSTALL) $(PROFILE_FILES) $(DESTDIR)/$(PROFILEDIR)
 	cd etc/env.d; $(INSTALL) $(ENV_FILES) $(DESTDIR)/$(ENVDIR)
+	cd etc/shrc.d; $(INSTALL) $(SHRC_FILES) $(DESTDIR)/$(SHRCDIR)
 
 dist: changelog clean
 	$(INSTALL) -d setup-$(VERSION)/etc/profile.d
diff --git a/etc/.cvsignore b/etc/.cvsignore
deleted file mode 100644
index 5561083..0000000
--- a/etc/.cvsignore
+++ /dev/null
@@ -1,2 +0,0 @@
-*~
-*.org
diff --git a/etc/shrc.d/256term.csh b/etc/shrc.d/256term.csh
new file mode 100644
index 0000000..a783f80
--- /dev/null
+++ b/etc/shrc.d/256term.csh
@@ -0,0 +1,28 @@
+# Enable 256 color capabilities for appropriate terminals
+
+# Set this variable in your local shell config if you want remote
+# xterms connecting to this system, to be sent 256 colors.
+# This can be done in /etc/csh.cshrc, or in an earlier profile.d script.
+#   set SEND_256_COLORS_TO_REMOTE=1
+#
+# To avoid enabling 256 color terminals set this variable in your local shell
+# config. This must be set before reading global initialization such as
+# /etc/csh.cshrc.
+#   set NO_256_COLORS=1
+
+# Terminals with any of the following set, support 256 colors (and are local)
+set local256="$?COLORTERM$?XTERM_VERSION$?ROXTERM_ID$?KONSOLE_DBUS_SESSION"
+
+if ($?TERM && (! $?NO_256_COLORS) && ($local256 || $?SEND_256_COLORS_TO_REMOTE)) then
+	switch ($TERM)
+	    case 'xterm':
+	    case 'screen':
+	    case 'Eterm':
+		setenv TERM "$TERM-256color"
+	endsw
+	if ($?TERMCAP && ($TERM == "screen-256color")) then
+		setenv TERMCAP $TERMCAP:s/Co#8/Co#256/
+	endif
+endif
+
+unset local256
diff --git a/etc/shrc.d/256term.sh b/etc/shrc.d/256term.sh
new file mode 100644
index 0000000..02bccfa
--- /dev/null
+++ b/etc/shrc.d/256term.sh
@@ -0,0 +1,32 @@
+# Enable 256 color capabilities for appropriate terminals
+
+# Set this variable in your local shell config (such as ~/.bashrc)
+# if you want remote xterms connecting to this system, to be sent 256 colors.
+# This must be set before reading global initialization such as /etc/bashrc.
+#   SEND_256_COLORS_TO_REMOTE=1
+#
+# To avoid enabling 256 color terminals set this variable in your local shell
+# config. This must be set before reading global initialization such as
+# /etc/bashrc.
+#   NO_256_COLORS=1
+
+# Terminals with any of the following set, support 256 colors (and are local)
+local256="$COLORTERM$XTERM_VERSION$ROXTERM_ID$KONSOLE_DBUS_SESSION"
+
+if [ -z "$NO_256_COLORS" ] && [ -n "$local256" -o -n "$SEND_256_COLORS_TO_REMOTE" ]; then
+	case "$TERM" in
+	  xterm|screen|Eterm)
+		  TERM=$TERM-256color
+		  ;;
+	esac
+	export TERM
+
+	if [ -n "$TERMCAP" ] && [ "$TERM" = "screen-256color" ]; then
+		if [[ "$TERMCAP" == *"Co#8"* ]]; then
+			TERMCAP="${TERMCAP%%Co#8*}Co#256${TERMCAP#*Co#8}"
+			export TERMCAP
+		fi
+	fi
+fi
+
+unset local256
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/setup.git/commitdiff/84c111d104ff6129825690bfb6160cb77825630e



More information about the pld-cvs-commit mailing list