Term Color List Generator
Author: lilydjwg
来自: http://p.vim-cn.com/cgj/sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# 显示终端色彩表 | |
mod=$1 | |
color () { | |
printf "\e[01;$mod;38;5;%sm%4s" $1 $1; | |
} | |
# 基本 16 色 | |
for i in {0..7}; do | |
color $i | |
done | |
echo | |
for i in {8..15}; do | |
color $i | |
done | |
echo;echo | |
for k in `seq 0 1`;do | |
for j in `seq $((16+k*18)) 36 $((196+k*18))`;do | |
for i in `seq $j $((j+17))`; do | |
printf "\e[01;$1;38;5;%sm%4s" $i $i; | |
done;echo; | |
done; | |
done | |
echo | |
# 灰色 | |
for i in {232..255}; do | |
color $i | |
done | |
echo |
PNG Crusher
Compress PNG file with Pngcrush.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Name of File: pngcrusher.sh | |
# Author: Vayn a.k.a. VT <vayn@vayn.de> | |
# Name: PNG Crusher | |
# Thanks To: Jyo <http://jyorr.com> | |
# License: | |
# Released under the MIT, BSD, and GPL Licenses. | |
# This is free software: you are free to change and redistribute it. | |
# There is NO WARRANTY, to the extent permitted by law. | |
E_BADDIR=65 | |
usage() { | |
echo "PNG Crusher extends function of Pngcrush to compress all png files in a directory. | |
Usage: `basename $0` [option]... [dir]... | |
-h help" | |
} | |
crush() { | |
dir=$(readlink -f "$1") | |
if [[ ! -d "$dir" ]]; then | |
echo "Cannot open \"$dir\" as directory." | |
exit $E_BADDIR | |
else | |
counter=0 | |
for filename in "$dir"/*; do | |
if [[ -f "$filename" && $(file "$filename" | awk '{print $2}') = PNG ]]; then | |
echo "Processing $filename" | |
pngcrush "$filename" "$filename.tmp" | |
mv "$filename.tmp" "filename" | |
((counter++)) | |
fi | |
done | |
if [[ $counter -gt 0 ]]; then | |
echo "$counter png file(s) processed." | |
exit 0 | |
else | |
echo "No png file found." | |
exit 1 | |
fi | |
fi | |
} | |
if [[ $# -eq 0 || "$1" = "-h" ]]; then | |
usage; | |
exit 0; | |
else | |
crush "$1" | |
fi |
Bin Sweeper
Delete all binary files in a directory.
Note: This script could be dangerous! THERE IS NO GUARANTEE! YOU USE THIS SCRIPT ON YOUR OWN RISK!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for filename in *; do [[ $(file "$filename" | awk '{print $2}') = ELF ]] && rm "$filename"; done; |
Simple Dictionary
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# @Author: Vayn a.k.a. VT <vayn@vayn.de> | |
# @Name: zenity_dict.sh | |
# @Date: 2011年04月28日 星期四 09时35分13秒 | |
# Released under the MIT, BSD, and GPL Licenses. | |
# This is free software: you are free to change and redistribute it. | |
# There is NO WARRANTY, to the extent permitted by law. | |
E_BADARGS=85 | |
MAXCONTEXTLINES=50 | |
DEFAULT_DICTFILE="/usr/share/dict/webster1913-dict.txt" | |
OUTFILE="/tmp/$0.output" | |
word=$(zenity --entry --title="Simple Dict" --text="Enter word, please:") | |
if [[ "$?" -ne 0 ]]; then | |
# Must at least specify word to look up. | |
zenity --error --text="\ | |
Usage: `basename $0` Word-to-define | |
-------------------------------------------- | |
Examples: Abandon, dictionary, etc." | |
exit $E_BADARGS | |
fi | |
dictfile=$(zenity --file-selection --filename="$DEFAULT_DICTFILE") | |
if [[ -z "$dictfile" ]]; then | |
dictfile=$DEFAULT_DICTFILE | |
fi | |
word=${word^} | |
fgrep -A $MAXCONTEXTLINES "$word" "$dictfile" | \ | |
sed -n '1,/^[A-Z]/p' | sed '$d' | sed '$d' > $OUTFILE | |
zenity --text-info --title="$word" --filename="$OUTFILE" | |
rm $OUTFILE | |
exit $? |
ddCodec
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# @Author: Vayn a.k.a. VT <vayn@vayn.de> | |
# @Name: ddenc.sh | |
# @Date: 2011年04月20日 星期三 16时00分29秒 | |
# Released under the MIT, BSD, and GPL Licenses. | |
# This is free software: you are free to change and redistribute it. | |
# There is NO WARRANTY, to the extent permitted by law. | |
# | |
# 用 dd 来进行简单的文本加解密 | |
E_BADARGS=65 | |
E_BADFILE=66 | |
usage() { | |
echo "Usage: `basename $0` [选项]... [文件]... | |
-e encode file | |
-d decode file | |
-h help" | |
} | |
file_test() { | |
if [[ ! -f $1 ]]; then | |
echo "Sorry, this is not a file." | |
exit $E_BADFILE | |
fi | |
} | |
if [[ -z "$@" ]]; then | |
usage | |
exit $E_BADARGS | |
fi | |
while getopts ":he:d:" Option; do | |
case $Option in | |
e) | |
file_test "${OPTARG}" | |
cat "${OPTARG}" | dd conv=swab,ebcdic > ${OPTARG}_encrypted | |
echo "Encoded successfully." | |
exit 0 | |
;; | |
d) | |
file_test "${OPTARG}" | |
cat "${OPTARG}" | dd conv=swab,ascii > ${OPTARG}_plaintext | |
echo "Decoded successfully." | |
exit 0 | |
;; | |
h) usage; exit 0;; | |
*) | |
usage | |
exit $E_BADARGS | |
;; | |
esac | |
done | |
usage | |
exit $E_BADARGS |
aDesc
A shell script, for saving man
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# @Author: Vayn a.k.a. VT <vayn@vayn.de> | |
# @Name: adesc.sh | |
# Released under the MIT, BSD, and GPL Licenses. | |
# This is free software: you are free to change and redistribute it. | |
# There is NO WARRANTY, to the extent permitted by law. | |
NO_ARGS=0 | |
E_ARGS=65 | |
E_CMD=127 | |
if [[ $# -eq $NO_ARGS ]]; then | |
echo "Usage: `basename $0` command [save]" | |
exit $E_ARGS | |
fi | |
echo | |
desc=`apropos -ers1 "^$1" | head -1` | |
if [[ ${#desc} -eq $NO_ARGS ]]; then | |
echo "Sorry, there is no man page for \"$1\"" | |
exit $E_ARGS | |
else | |
echo -e "$desc\012" | |
if [[ $2 = 'save' ]]; then | |
man -l -Tps `man -w "$1"` | ps2pdf - "$1".pdf 2>/dev/null | |
if [[ $? -eq $E_CMD ]]; then | |
echo "Sorry, it failed to convert manpage to PDF." | |
echo "Please install ps2pdf tool." | |
exit $E_CMD | |
else | |
echo "Converted manpage of \"$1\" to PDF successfully." | |
echo "`pwd`/$1.pdf" | |
fi | |
fi | |
fi |