#! /bin/zsh # # this file: # http://user.it.uu.se/~embe8573/conf/.zsh/ide # https://dataswamp.org/~incal/conf/.zsh/ide find-duplicate-lines () { local file=$1 cat $file | sort | uniq -d } alias dups=find-duplicate-lines create-100-meg-bogus-file () { local file=${1:-100.data} rm $file dd if=/dev/urandom \ of=$file \ count=$(( 1024 * 100 )) \ bs=1024 | sha256sum | ( read rnd _; echo $rnd >> $file ) } create-bogus-file () { local file=$1 local lines=$2 rm -r $file for l in {0..$lines}; do dd if=/dev/urandom count=1 2> /dev/null | sha256sum | ( read rnd _; echo $rnd >> $file ) done } alias cbf=create-bogus-file last-cmd () { history | tail -n 1 | cut -d ' ' -f 5- } indent-files () { local -a files for f in $@; do files+=\"$f\" done emacs -Q --batch -l cl --eval " (dolist (filename (list $files)) (find-file filename) (indent-region (point-min) (point-max)) (save-buffer) (kill-buffer) )" } # make alias make='make -s -j -k' alias ma='make all' alias maa='make again' emake () { local emacs_path=~/.emacs.d/emacs-init make $@ -C $emacs_path } alias em='emake' alias ema='emake again' # scripts cats () { local file=~/scripts/$1 [[ -f $file ]] && cat $file } # 't' is an extention of zsh's 'whence' ("t" # for "type"). It outputs what file the # function or alias is defined, and it uses # 'whence' to output the definition or code. # If the argument command is a script, 't' uses # 'cats' ("catenate script") to output it. t () { # check number of arguments if [[ $# == 0 ]]; then echo "syntax: $0 COMMAND" >&2 return fi local cmd=$1 find-zsh-command $cmd # use whence; if a path, do 'ls' local whence_hits whence_hits=("${(@f)$(whence -ca $cmd | sed "s#$HOME#~#g")}") local h for h in $whence_hits; do echo $h ls -Ghl --color=auto $h 2> /dev/null if [ -h $h ]; then local dest=$(readlink -e $h) set-fg-color 3 echo -n " * links to: " reset-color echo -n $dest '\n ' ls -Ghl --color=auto $dest fi done # if a script, output it cats $cmd }