Added Cygxcolors & hostconf

This commit is contained in:
斟酌 鵬兄 2014-07-29 09:50:44 +08:00
parent 1563dffba8
commit 56a34a1f12
6 changed files with 153 additions and 1 deletions

2
.gitignore vendored
View File

@ -1,2 +1,2 @@
*.prod
*.log

32
bash/cygxcolors/Solarized Normal file
View File

@ -0,0 +1,32 @@
! Common
#define S_yellow #b58900
#define S_orange #cb4b16
#define S_red #dc322f
#define S_magenta #d33682
#define S_violet #6c71c4
#define S_blue #268bd2
#define S_cyan #2aa198
#define S_green #859900
! Dark
#define S_base03 #222222
#define S_base02 #073642
#define S_base01 #586e75
#define S_base00 #657b83
#define S_base0 #839496
#define S_base1 #93a1a1
#define S_base2 #eee8d5
#define S_base3 #fdf6e3
! Light
! #define S_base03 #fdf6e3
! #define S_base02 #eee8d5
! #define S_base01 #93a1a1
! #define S_base00 #839496
! #define S_base0 #657b83
! #define S_base1 #586e75
! #define S_base2 #073642
! #define S_base3 #002b36

View File

@ -0,0 +1,3 @@
XTerm*font: 9x15
XTerm*saveLines: 1000
XTerm*geometry: 145x35

80
bash/cygxcolors/applyXColors.sh Executable file
View File

@ -0,0 +1,80 @@
#!/bin/bash
CONF_FILE=$1
TARGET_X=~/.Xdefaults
[ ! -f $CONF_FILE ] && exit;
function getColor() {
if [[ -n "$1" ]]; then
grep -E "^[ ]*#define.+S_$1[ ]+" $CONF_FILE | awk '{print $3}'
fi
}
X_BEGIN_STR="!! ~~~~ BEGIN COLOR SETTINGS ~~~~ !!"
X_END_STR="!! ~~~~ END COLOR SETTINGS ~~~~ !!"
ORIGX=""
if [ -f $TARGET_X ]; then
SKIP=false
while read line;
do
if [ "$line" = "$X_BEGIN_STR" ]; then
SKIP=true
continue
elif [ "$line" = "$X_END_STR" ]; then
SKIP=false
continue
fi
if [ $SKIP = false ] && [ -n "$line" ]; then
ORIGX="$ORIGX$line\n"
fi
done < $TARGET_X
fi
CNAMES=( yellow orange red magenta violet blue cyan green base0 base1 base2 base3 base00 base01 base02 base03 )
declare -A COLORS=()
for i in "${CNAMES[@]}"
do
COLORS[$i]=$( getColor $i )
done
SETTINGS=""
function push_val() {
SETTINGS=$SETTINGS"$1\n"
}
push_val
push_val "$X_BEGIN_STR"
push_val "*VT100*background: ${COLORS['base03']}"
push_val "*VT100*foreground: ${COLORS['base0']}"
push_val "*VT100*fading: 40"
push_val "*VT100*fadeColor: ${COLORS['base08']}"
push_val "*VT100*cursorColor: ${COLORS['base1']}"
push_val "*VT100*pointerColorBackground: ${COLORS['base01']}"
push_val "*VT100*pointerColorForeground: ${COLORS['base1']}"
push_val "*VT100*color0: ${COLORS['base02']}"
push_val "*VT100*color1: ${COLORS['red']}"
push_val "*VT100*color2: ${COLORS['green']}"
push_val "*VT100*color3: ${COLORS['yellow']}"
push_val "*VT100*color4: ${COLORS['blue']}"
push_val "*VT100*color5: ${COLORS['magenta']}"
push_val "*VT100*color6: ${COLORS['cyan']}"
push_val "*VT100*color7: ${COLORS['base2']}"
push_val "*VT100*color8: ${COLORS['base03']}"
push_val "*VT100*color9: ${COLORS['orange']}"
push_val "*VT100*color10: ${COLORS['base01']}"
push_val "*VT100*color11: ${COLORS['base00']}"
push_val "*VT100*color12: ${COLORS['base0']}"
push_val "*VT100*color13: ${COLORS['violet']}"
push_val "*VT100*color14: ${COLORS['base1']}"
push_val "*VT100*color15: ${COLORS['base3']}"
push_val "$X_END_STR"
echo -e "$ORIGX\n$SETTINGS" > $TARGET_X

30
bash/hostconf/apply.sh Executable file
View File

@ -0,0 +1,30 @@
#!/bin/bash
if [ -f $1 ]; then
source $1
fi
uname | grep -q Linux
LINUX=$?
if [ "$LINUX" -eq "0" ]; then
HOST=/etc/hosts
else
HOST=/cygdrive/c/Windows/System32/drivers/etc/hosts
fi
if [ ${HOSTNAMES[0]+1} ]; then
for i in {0..99};
do
if [ ${HOSTNAMES[$i]+1} ]; then
XID="# Automated Host Def. Id. $i"
if grep -q "$XID" $HOST; then
REC=$( echo "s/.*$XID$/${HOSTNAMES[$i]}\ $XID/g" | sed "s/\ /\\\ /g" )
sed -i "$REC" $HOST
else
echo ${HOSTNAMES[$i]} $XID >> $HOST
fi
fi
done
fi

7
bash/hostconf/noconf Normal file
View File

@ -0,0 +1,7 @@
#!/bin/bash
HOSTNAMES=()
for i in {0..99}; do
HOSTNAMES[$i]=""
done