3 # Found in the mailinglistarchive from Zsh (IIRC ~1996)
4 #f5# Select items for specific command(s) from history
9 echo "Usage: $0 command"
12 cmd
=(${(f)"$(grep -w $1 $HISTFILE | sort | uniq | pr -tn)"})
13 print
-l $cmd |
less -F
14 echo -n "enter number of desired command [1 - $(( ${#cmd[@]} - 1 ))]: "
17 print
-z "${cmd[$answer]#*$TAB}"
20 # Use vim to convert plaintext to HTML
21 #f5# Transform files to html with highlighting
24 vim
-u NONE
-n -c ':syntax on' -c ':so $VIMRUNTIME/syntax/2html.vim' -c ':wqa' $1 &>/dev
/null
27 # function readme() { $PAGER -- (#ia3)readme* }
28 #f5# View all README-like files in current directory in pager
32 files
=(.
/(#i)*(read*me|lue*m(in|)ut)*(ND))
36 print
'No README files.'
40 # function ansi-colors()
41 #f5# Display ANSI colors
43 typeset esc
="\033[" line1 line2
44 echo " _ _ _40 _ _ _41_ _ _ _42 _ _ 43_ _ _ 44_ _ _45 _ _ _ 46_ _ _ 47_ _ _ 49_ _"
45 for fore
in 30 31 32 33 34 35 36 37; do
48 for back
in 40 41 42 43 44 45 46 47 49; do
49 line1
="${line1}${esc}${back};${fore}m Normal ${esc}0m"
50 line2
="${line2}${esc}${back};${fore};1m Bold ${esc}0m"
52 echo -e "$line1\n$line2"
56 # % slow_print `cat /etc/passwd`
57 #f5# Slowly print out parameters
59 for argument
in "$@" ; do
60 for ((i
= 1; i
<= ${#1} ;i
++)) ; do
61 print
-n "${argument[i]}"
74 cdrdao read-cd
--device $DEVICE --driver generic-mmc audiocd.toc
75 cdrdao read-cddb
--device $DEVICE --driver generic-mmc audiocd.toc
76 echo " * Would you like to burn the cd now? (yes/no)"
78 if [[ "$input" = "yes" ]] ; then
79 echo " ! Burning Audio CD"
83 echo " ! Invalid response."
88 #f5# Burn an audio CD (in combination with audiorip)
91 cdrdao
write --device $DEVICE --driver generic-mmc audiocd.toc
92 echo " * Should I remove the temporary files? (yes/no)"
94 if [[ "$input" = "yes" ]] ; then
95 echo " ! Removing Temporary Files."
100 echo " ! Invalid response."
104 #f5# Make an audio CD from all mp3 files
106 # TODO: do the renaming more zshish, possibly with zmv()
109 for i
in *.
[Mm
][Pp
]3; do mv "$i" `echo $i | tr '[A-Z]' '[a-z]'`; done
110 for i
in *.mp3
; do mv "$i" `echo $i | tr ' ' '_'`; done
111 for i
in *.mp3
; do mpg123
-w `basename $i .mp3`.wav
$i; done
113 for i
in *.wav
; do sox
$i.wav
-r 44100 $i.wav resample
; done
116 #f5# Create an ISO image. You are prompted for\\&\quad volume name, filename and directory
119 echo " * Volume name "
121 echo " * ISO Name (ie. tmp.iso)"
123 echo " * Directory or File"
125 mkisofs
-o ~
/$iso -A $volume -allow-multidot -J -R -iso-level 3 -V $volume -R $files
128 #f5# Simple thumbnails generator
130 rm -rf thumb-
* index.html
134 <title>Images</title>
137 for f
in *.
(gif|jpeg|jpg|png
) ; do
138 convert
-size 100x200
"$f" -resize 100x200 thumb-
"$f"
139 echo " <a href=\"$f\"><img src=\"thumb-$f\"></a>" >> index.html
143 </html>" >> index.html
146 #f5# Set all ulimit parameters to \kbd{unlimited}
157 # ogg2mp3 with bitrate of 192
160 oggdec
-o - $1 | lame
-b 192 - ${1:r}.mp3
163 #f5# Install x-lite (VoIP software)
167 [[ -d ~
/tmp
]] || mkdir ~
/tmp
170 echo "Downloading http://www.counterpath.com/download/X-Lite_Install.tar.gz and storing it in ~/tmp:"
171 if wget http
://www.counterpath.com
/download
/X-Lite_Install.
tar.gz
; then
172 unp X-Lite_Install.
tar.gz
&& echo done ||
echo failed
174 echo "Error while downloading." ; return 1
177 if [[ -x xten-xlite
/xtensoftphone
]] ; then
178 echo "Execute xten-xlite/xtensoftphone to start xlite."
186 echo "Downloading debian package of skype."
187 echo "Notice: If you want to use a more recent skype version run 'getskypebeta'."
188 wget http
://www.skype.com
/go
/getskype-linux-deb
189 $SUDO dpkg
-i skype
*.deb
&& echo "skype installed."
192 #f5# Install beta-version of skype
196 echo "Downloading debian package of skype (beta version)."
197 wget http
://www.skype.com
/go
/getskype-linux-beta-deb
198 $SUDO dpkg
-i skype-beta
*.deb
&& echo "skype installed."
201 #f5# Install gizmo (VoIP software)
205 echo "libgtk2.0-0, gconf2, libstdc++6, libasound2 and zlib1g have to be available. Installing."
207 $SUDO apt-get
install libgtk2.0
-0 gconf2 libstdc
++6 libasound2 zlib1g
208 wget
"$(lynx --dump http://gizmo5.com/pc/download/linux/ | awk '/libstdc\+\+6.*\.deb/ {print $2}')"
209 $SUDO dpkg
-i gizmo-project
*.deb
&& echo "gizmo installed."
212 #f5# Get and run AIR (Automated Image and Restore)
216 [[ -w .
]] ||
{ echo 'Error: you do not have write permissions in this directory. Exiting.' ; return 1 }
218 wget http
://puzzle.dl.sourceforge.net
/sourceforge
/air-imager
/air-
$VER.
tar.gz
219 tar zxf air-
$VER.
tar.gz
221 INTERACTIVE
=no
$SUDO .
/install-air-1.2
.8
222 [[ -x /usr
/local
/bin
/air
]] && [[ -n "$DISPLAY" ]] && $SUDO air
225 # http://strcat.de/blog/index.php?/archives/335-Software-sauber-deinstallieren...html
226 #f5# Log 'make install' output
229 [[ ! -d ~
/.errorlogs
]] && mkdir ~
/.errorlogs
230 make -n install > ~
/.errorlogs
/${PWD##*/}-makelog
233 # usage example: 'lcheck strcpy'
234 #f5# Find out which libs define a symbol
236 if [[ -n "$1" ]] ; then
237 nm
-go /usr
/lib
/lib
*.a
2>/dev
/null |
grep ":[[:xdigit:]]\{8\} . .*$1"
239 echo "Usage: lcheck <function>" >&2
243 # make sure it is not assigned yet
244 [[ -n ${aliases[utf2iso]} ]] && unalias utf2iso
247 for ENV
in $
(env |
command grep -i '.utf') ; do
248 eval export "$(echo $ENV | sed 's/UTF-8/iso885915/ ; s/utf8/iso885915/')"
253 # make sure it is not assigned yet
254 [[ -n ${aliases[iso2utf]} ]] && unalias iso2utf
257 for ENV
in $
(env |
command grep -i '\.iso') ; do
258 eval export "$(echo $ENV | sed 's/iso.*/UTF-8/ ; s/ISO.*/UTF-8/')"
263 # if cdrecord is a symlink (to wodim) or isn't present at all warn:
264 if [[ -L /usr
/bin
/cdrecord
]] ||
! check_com
-c cdrecord
; then
265 if check_com
-c wodim
; then
268 cdrecord is not provided under its original name by Debian anymore.
269 See #377109 in the BTS of Debian for more details.
271 Please use the wodim binary instead
278 # get_tw_cli has been renamed into get_3ware
279 if check_com
-c get_3ware
; then
281 echo 'Warning: get_tw_cli has been renamed into get_3ware. Invoking get_3ware for you.'>&2
286 ###############################
287 # When I was young… #
288 ###############################
291 COMMAND
=$
(tail -n 2 ~
/.zsh
/history-
$h |
head -n 1)
292 COMMAND
=${COMMAND#*;}
293 COMMAND
=$
(echo $COMMAND |
sed -e "s/^sudo //")
294 echo "sudo ${COMMAND}" | zsh
298 key
="${1%\=*}" ; val
="${1#*\=}"
299 strictkey
="${1%%\=*}" ; strictval
="${1##*\=}"