From d0571f211ce0c78ae7f88cbe089fc82bf8de65a3 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Tue, 31 Dec 2013 07:32:25 -0500 Subject: [PATCH] Initial svn import --- design | 65 +++++++++++++++++++ startup_hooks/login | 37 +++++++++++ startup_hooks/tcshrc | 41 ++++++++++++ tcshrc | 78 +++++++++++++++++++++++ tcshrc.alias | 0 tcshrc.colors | 58 +++++++++++++++++ tcshrc.prompt | 8 +++ tcshrc.prompt.colors | 40 ++++++++++++ tcshrc.prompt.defs | 0 tcshrc.system | 40 ++++++++++++ tcshrc.system.Linux | 15 +++++ tcshrc.system.common | 148 +++++++++++++++++++++++++++++++++++++++++++ 12 files changed, 530 insertions(+) create mode 100644 design create mode 100644 startup_hooks/login create mode 100644 startup_hooks/tcshrc create mode 100644 tcshrc create mode 100644 tcshrc.alias create mode 100644 tcshrc.colors create mode 100644 tcshrc.prompt create mode 100644 tcshrc.prompt.colors create mode 100644 tcshrc.prompt.defs create mode 100644 tcshrc.system create mode 100644 tcshrc.system.Linux create mode 100644 tcshrc.system.common diff --git a/design b/design new file mode 100644 index 0000000..10a4ea9 --- /dev/null +++ b/design @@ -0,0 +1,65 @@ +In-order steps of initialization + + +Initial check for tty or not. + +Find core OS name from kernel with "uname". + +Different OSes need different uname breakdowns to find out stats. + +determine what system fix-ups are needed for common commands. + + -- build a later version of shell? + + +Load basic environment configuration variables (login or not) + +decide if login or batch-session. + + +For batch: Load batch-specific settings. + + + +Otherwise: +Switch to TCSH loading. + +Load login for first login bits. +Load tcshrc for first login bits. + + -- First launch tcshrc + + -- These are sourced from tcshrc.system +Load arch specific tcshrc bits +Load OS specific tcshrc bits +Load machine speciifc tchsrc bits +Load organization/network specific tcshrc bits +Load user specific tcshrc bits + + +-- These get launched by tcshrc.alias +Load arch specific alias bits +Load OS specific alias bits +Load machine speciifc tchsrc bits +Load organization/network specific alias bits +Load user specific alias bits + +Load arch specific completion bits +Load OS specific completion bits +Load machine speciifc tchsrc bits +Load organization/network specific completion bits +Load user specific completion bits + +Load arch specific bindkey bits +Load OS specific bindkey bits +Load machine speciifc tchsrc bits +Load organization/network specific bindkey bits +Load user specific bindkey bits + + -- Do prompt last, since it is not that useful beforehand. +Load tcshrc prompt + +---------------------------------------------- + + +Start by acknowledging that both login and tcshrc are sourced. diff --git a/startup_hooks/login b/startup_hooks/login new file mode 100644 index 0000000..ce8a889 --- /dev/null +++ b/startup_hooks/login @@ -0,0 +1,37 @@ +set login_sourced + +if( $?CSHENV_DEBUG ) then + echo "Starting login..." +endif + +#if( ! $?CSHENV_DIR ) then + #setenv CSHENV_DIR ~/proj/cshenv +#endif + +#echo "Under: " $_ +#echo "Zero: " $0 + +#if( -n "${_}" ) then +# echo $0 +# setenv CSHENV_LOGIN_PATH $0 +#else +# echo ${_}:1 +# setenv CSHENV_LOGIN_PATH "${_}:1" +#else +#endif + +#echo login hook lives at: ${CSHENV_LOGIN_PATH} + + +if( $?CSHENV_DEBUG ) then + echo "Ending login..." +endif + +########################### +# vim: ft=tcsh +########################### + +setenv LC_NUMERIC en_US.UTF-8 +setenv LC_MEASUREMENT en_US.UTF-8 +setenv LC_MONETARY en_US.UTF-8 +setenv LC_TIME en_US.UTF-8 diff --git a/startup_hooks/tcshrc b/startup_hooks/tcshrc new file mode 100644 index 0000000..2f4aab1 --- /dev/null +++ b/startup_hooks/tcshrc @@ -0,0 +1,41 @@ +set tcshrc_sourced + +if( $?CSHENV_DEBUG ) then + echo "Starting tcshrc..." +endif + +if( ! $?CSHENV_DIR ) then + setenv CSHENV_DIR ~/proj/cshenv +endif + +if( $?CSHENV_DEBUG ) then + echo "Setup CSHENV_DIR to: " ${CSHENV_DIR} +endif + +#if( -z ${_} ) then + #echo $0 + #setenv CSHENV_TCSHRC_PATH $0 +#else + #echo ${_} + #setenv CSHENV_TCSHRC_PATH "${_}" +#endif + +#echo tcshrc hook lives at: ${CSHENV_TCSHRC_PATH} + +if( -c `tty` ) then + if( $?CSHENV_DEBUG ) then + echo "Going to source core tcshrc..." + endif + source ${CSHENV_DIR}/tcshrc +endif + +# Not using tcshrc bits for non-login shells. Will decide what to do later. + +if( $?CSHENV_DEBUG ) then + echo "Ending tcshrc..." +endif + +########################### +# vim: ft=tcsh +########################### + diff --git a/tcshrc b/tcshrc new file mode 100644 index 0000000..ca5722f --- /dev/null +++ b/tcshrc @@ -0,0 +1,78 @@ +# CSHRC Debugging tests +if( ( $?CSHENV_DEBUG ) || ( $?CSHENV_VERBOSE_STARTUP ) ) then + echo "Currently running tcshrc script" +endif + + +# Figure out what kind of tcsh we are running. +if( $?tcsh ) then + set tcsh_major=$tcsh:r:r + set tcsh_minor=$tcsh:r:e + set tcsh_patch=$tcsh:e + set tcsh_features=$version:as/ /.:as/,/./ + + if( $tcsh_minor < 12 ) then + echo "We are on a very ancient TCSH! There may be many problems..." + else + if( $tcsh_minor == 14 && $tcsh_patch < 2 ) then + if( $?CSHENV_DEBUG ) then + echo "We may not have ADAM's patches..." + endif + endif + endif + +else + # As we develop support for C++sh, we'll need this + if( !$?cxxsh ) then + echo "What! We're not even in tcsh or something compatible, like C++sh!!!" + endif +endif + +set cur_feature=$tcsh_features:e + +if( $?CSHENV_DEBUG ) then + echo "Tcsh Featureset probed..." +endif + + + + + +#The history size for your shell can be set globally now +if( $?CSHENV_HISTORY_SIZE ) then + set history=$HISTORY_SIZE +endif + +# this safe_source alias is incredibly delicate. It drives the whole +# optional sourcing mechanism -- DO NOT MESS WITH IT! +alias safe_source 'eval "if ( -f \!:1 ) then \\ +source \!:1 \\ +endif"' + +if( $?CSHENV_DEBUG ) then + echo "Tcsh safe-source alias constructed..." +endif + +# Dispatch to find out what our OS is and any fixups +# This will figure out what system we're on and setup all +# system specific notions. From the sourced file, +# tcshrc.system.???? will be called +if( $?CSHENV_DEBUG ) then + echo "Trying to source tcshrc.system" +endif +source ${CSHENV_DIR}/tcshrc.system + +if( $?CSHENV_DEBUG ) then + echo "Trying to source tcshrc.alias" +endif +source ${CSHENV_DIR}/tcshrc.alias + +if( $?CSHENV_DEBUG ) then + echo "Trying to source tcshrc.prompt" +endif +source ${CSHENV_DIR}/tcshrc.prompt + +########################### +# vim: ft=tcsh +########################### + diff --git a/tcshrc.alias b/tcshrc.alias new file mode 100644 index 0000000..e69de29 diff --git a/tcshrc.colors b/tcshrc.colors new file mode 100644 index 0000000..eb2d935 --- /dev/null +++ b/tcshrc.colors @@ -0,0 +1,58 @@ +####################### +####### COLOURS ####### +####################### + +set csi='[' + +set ansi_bright='1' +set ansi_dim='0' +set ansi_color='m' + +set ansi_black='30' +set ansi_red='31' +set ansi_green='32' +set ansi_yellow='33' +set ansi_blue='34' +set ansi_magenta='35' +set ansi_cyan='36' +set ansi_white='37' + + +set bright="$csi$ansi_bright$ansi_color" +set dim="$csi$ansi_dim$ansi_color" + + +set black="$csi$ansi_black$ansi_color" +set red="$csi$ansi_red$ansi_color" +set green="$csi$ansi_green$ansi_color" +set yellow="$csi$ansi_yellow$ansi_color" +set blue="$csi$ansi_blue$ansi_color" +set magenta="$csi$ansi_magenta$ansi_color" +set cyan="$csi$ansi_cyan$ansi_color" +set white="$csi$ansi_white$ansi_color" + + + +set dim_black="$csi$ansi_dim;$ansi_black$ansi_color" +set dim_red="$csi$ansi_dim;$ansi_red$ansi_color" +set dim_green="$csi$ansi_dim;$ansi_green$ansi_color" +set dim_yellow="$csi$ansi_dim;$ansi_yellow$ansi_color" +set dim_blue="$csi$ansi_dim;$ansi_blue$ansi_color" +set dim_magenta="$csi$ansi_dim;$ansi_magenta$ansi_color" +set dim_cyan="$csi$ansi_dim;$ansi_cyan$ansi_color" +set dim_white="$csi$ansi_dim;$ansi_white$ansi_color" + + +set bright_black="$csi$ansi_bright;$ansi_black$ansi_color" +set bright_red="$csi$ansi_bright;$ansi_red$ansi_color" +set bright_green="$csi$ansi_bright;$ansi_green$ansi_color" +set bright_yellow="$csi$ansi_bright;$ansi_yellow$ansi_color" +set bright_blue="$csi$ansi_bright;$ansi_blue$ansi_color" +set bright_magenta="$csi$ansi_bright;$ansi_magenta$ansi_color" +set bright_cyan="$csi$ansi_bright;$ansi_cyan$ansi_color" +set bright_white="$csi$ansi_bright;$ansi_white$ansi_color" + + +########################### +# vim:filetype=tcsh +########################### diff --git a/tcshrc.prompt b/tcshrc.prompt new file mode 100644 index 0000000..8e010e9 --- /dev/null +++ b/tcshrc.prompt @@ -0,0 +1,8 @@ +source ${CSHENV_DIR}/tcshrc.colors +source ${CSHENV_DIR}/tcshrc.prompt.colors +source ${CSHENV_DIR}/tcshrc.prompt.defs + +########################### +# vim:filetype=csh +########################### + diff --git a/tcshrc.prompt.colors b/tcshrc.prompt.colors new file mode 100644 index 0000000..d0c71a9 --- /dev/null +++ b/tcshrc.prompt.colors @@ -0,0 +1,40 @@ +###################### +### PROMPT COLOURS ### +###################### + + +set date_color="${dim_magenta}" +set time_color="${bright_magenta}" +set text_color="${bright_white}" +set oldp_color="${dim_white}" +set brace_color="${bright_yellow}" +set host_color="${bright_blue}" +set name_color="${bright_cyan}" +set at_color="${dim_cyan}" +set path_color="${bright_green}" +set line_color="${dim_red}" +set prompt_color="${dim_white}" +set depth_color="${dim_yellow}" +set command_color="${dim_white}" + +set color_start="%{" +set color_end="%}" + +set date_color_seq="${color_start}${date_color}${color_end}" +set time_color_seq="${color_start}${time_color}${color_end}" +set text_color_seq="${color_start}${text_color}${color_end}" +set oldp_color_seq="${color_start}${oldp_color}${color_end}" +set brace_color_seq="${color_start}${brace_color}${color_end}" +set host_color_seq="${color_start}${host_color}${color_end}" +set name_color_seq="${color_start}${name_color}${color_end}" +set at_color_seq="${color_start}${at_color}${color_end}" +set path_color_seq="${color_start}${path_color}${color_end}" +set line_color_seq="${color_start}${line_color}${color_end}" +set prompt_color_seq="${color_start}${prompt_color}${color_end}" +set depth_color_seq="${color_start}${depth_color}${color_end}" +set command_color_seq="${color_start}${command_color}${color_end}" + + +########################### +# vim:filetype=tcsh +########################### diff --git a/tcshrc.prompt.defs b/tcshrc.prompt.defs new file mode 100644 index 0000000..e69de29 diff --git a/tcshrc.system b/tcshrc.system new file mode 100644 index 0000000..7ff64d8 --- /dev/null +++ b/tcshrc.system @@ -0,0 +1,40 @@ +if( $?CSHENV_DEBUG ) then + echo "Running tcshrc.system..." +endif + +setenv CSHENV_SYSTEM `uname` + +if( $?CSHENV_DEBUG ) then + echo 'Initially detected that you are running on a "'${CSHENV_SYSTEM}'" system' +endif + + + +# Cygwin systems are kinda funky -- so we fix them up to say "Cygwin" +switch( ${CSHENV_SYSTEM} ) + case CYGWIN_NT-6.1-WOW64: + setenv CSHENV_SYSTEM Cygwin + breaksw +endsw + +if( $?CSHENV_DEBUG ) then + echo 'Detected that you are running on a "'${CSHENV_SYSTEM}'" system' +endif + + +# Source the common bits, since many systems often have lots in common. +# For the moment, everything is in here. +# This file is DEPRECATED from the start! +source ${CSHENV_DIR}/tcshrc.system.common + + +# Systems may need many system specific fixes for their systems +# Such bits go into system-specific files. +safe_source ${CSHENV_DIR}/tcshrc.system.${CSHENV_SYSTEM} +if( ! $?CSHENV_SYSTEM_CONFIGURED ) then + echo 'Warning- Unable to find a proper system configuration set for "'${CSHENV_SYSTEM}'"' +endif + +########################### +# vim: ft=tcsh +########################### diff --git a/tcshrc.system.Linux b/tcshrc.system.Linux new file mode 100644 index 0000000..85e8fa1 --- /dev/null +++ b/tcshrc.system.Linux @@ -0,0 +1,15 @@ +if( $?CSHENV_DEBUG ) then + echo "Sourcing tcshrc.system.Linux..." +endif + +# Set the acknowledgement bit, essentially +setenv CSHENV_SYSTEM_CONFIGURED Linux + +if( $?CSHENV_DEBUG ) then + echo "Done sourcing tcshrc.system.Linux..." +endif + +########################### +# vim: ft=tcsh +########################### + diff --git a/tcshrc.system.common b/tcshrc.system.common new file mode 100644 index 0000000..4cb8322 --- /dev/null +++ b/tcshrc.system.common @@ -0,0 +1,148 @@ +if( $?CSHENV_DEBUG ) then + echo "Sourcing tcshrc.system.common" +endif + +set uname=`uname` +set uname_a=`uname -a` +set uname_p=`uname -p` +set uname_m=`uname -m` + +if( $?CSHENV_DEBUG ) then + echo "Setting uname -i tracker, based upon OS." +endif + +switch( ${CSHENV_SYSTEM} ) + case Cygwin: + case Darwin: + case Linux + set uname_i + breaksw + + default: + #FALLTHROUGH + + case FreeBSD: + case NetBSD: + set uname_i="`uname -i`" + breaksw +endsw + +if( $?CSHENV_DEBUG ) then + echo "Setting CSHENV_BASESYSTEM..." +endif +setenv CSHENV_BASESYSTEM "${uname}" + +if( $?CSHENV_DEBUG ) then + echo "Setting CSHENV_FULLSYSTEM..." +endif +setenv CSHENV_FULLSYSTEM "${uname_a}" + +switch ( ${CSHENV_SYSTEM} ) + + case Cygwin: + if( $?CSHENV_DEBUG ) then + echo "Using a Cygwin system..." + endif + + #Cygwin is like Linux, so we just... + + #FALLTHROUGH + + case Linux: + if( $?CSHENV_DEBUG ) then + echo "Using a Linux-like system (GLIBC, probably)..." + endif + + setenv CSHENV_CPU "${uname_m}" + setenv CSHENV_MACH "${uname_p}" + + switch( CSHENV_CPU ) + case m68k: + if( $?CSHENV_DEBUG ) then + echo "Running on a m68k based CPU, tweaks for system." + endif + + setenv CSHENV_ARCH ${uname_p} + breaksw + + case armv71: + if( $?CSHENV_DEBUG ) then + echo "Running on an arm based CPU, tweaks for system." + endif + setenv CSHENV_ARCH arm + breaksw + + default: + setenv CSHENV_ARCH ${uname_i} + breaksw + endsw + + breaksw + + case Darwin: + if( $?CSHENV_DEBUG ) then + echo "Using a Darwin/MacosX system..." + endif + + setenv CSHENV_CPU ${uname_p} + setenv CSHENV_MACH ${uname_m} + + #TODO: Fix this for intel vs. ppc check. + setenv CSHENV_ARCH ppc + breaksw + + case FreeBSD: + if( $?CSHENV_DEBUG ) then + echo "Using a FreeBSD system..." + endif + + setenv CSHENV_CPU ${uname_p} + setenv CSHENV_MACH ${uname_m} + setenv CSHENV_ARCH ${uname_p} + breaksw + + default: + setenv CSHENV_CPU ${uname_p} + setenv CSHENV_MACH ${uname_m} + setenv CSHENV_ARCH ${uname_i} + breaksw +endsw + +if( $?CSHENV_DEBUG ) then + echo "Detecting hostname hacks needed." +endif + +switch( ${CSHENV_SYSTEM} ) + + #Broken or Non-BSD like hostname commands: + case Cygwin: + case SunOS: + if( $?CSHENV_DEBUG ) then + echo "SYSV hostname hack." + endif + + setenv CSHENV_HOSTNAME `hostname | tr "[:upper:]" "[:lower:]"` + breaksw + + #BSD like hostnames, and non-broken ones. + default: + if( $?CSHENV_DEBUG ) then + echo "BSD-like hostname hack." + endif + + setenv CSHENV_HOSTNAME `hostname -s| tr "[:upper:]" "[:lower:]"` + breaksw +endsw + +if( $?CSHENV_DEBUG ) then + echo "Hostname detected as ${CSHENV_HOSTNAME}..." +endif + +if( $?CSHENV_DEBUG ) then + echo "Done sourcing tcshrc.system.common" +endif + +########################### +# vim: ft=tcsh +########################### +