[talk] I declare not so stupid unix tricks thread open

Mischa Diehm md at mailq.de
Sat Mar 15 05:38:04 EDT 2014


On systems that have lsof  (could probably be changed for fstat): 

# fast changedir to directories already open by other shells
fcd () {
        COUNT=0
        lsof -d cwd | grep '^bash' | sed -e 's/^.* \///' | \
            sort -u | grep -v '^home/mischa$' | while read i; do COUNT=$((COUNT+1)); echo "[$COUNT] /$i";  done

        read j;

        case $j in
            [1-9])
            DIR="/$(lsof -d cwd | grep '^bash' | sed -e 's/^.* \///' | sort -u | \
                grep -v '^home/mischa$' | sed -n ${j}p)"

                if [ "$DIR" != "/" ]; then
                    cd "$DIR"
                fi

                ;;
            *)
                ;;
        esac
}


[10:23:03] mischa at lebenske:include$ fcd
[1] /Users/mischa
[2] /Users/mischa/bin
[3] /Users/mischa/x40
[4] /usr/local/Cellar/yubikey-personalization
[5] /usr/local/include
4
[10:23:14] mischa at lebenske:yubikey-personalization$

==

#local manpages
lman () { nroff -e -man "$1" | less -s
}

[10:34:50] mischa at lebenske:tek$ lman plan9/sys/man/8/wol

==

#jump to search with vim
vipat () { vim -R +/$1 `egrep -Rl $1 .`
}

cheers,
Mischa

On 15.03.2014, at 00:26, George Rosamond <george at ceetonetechnology.com> wrote:

> Jason Hellenthal:
>> These should all be posix compliant sh(1) FreeBSD compatible. Not sure
>> about other systems.
>> 
>> # Kill or list some stopped processes
>> alias stopkill='kill `ps a -o stat,pid |awk '\''/^T /{print $2}'\''`'
>> alias stoplist='ps -p `ps a -o stat,pid |awk '\''/^T /{print $2}'\''`
>> 2>/dev/null'
>> 
>> # Kill or list some zombies
>> alias zomkill='kill `ps a -o stat,pid |awk '\''/^Z /{print $2}'\''`'
>> alias zomlist='ps -p `ps a -o stat,pid |awk '\''/^Z /{print $2}'\''`
>> 2>/dev/null'
> 
> 
> Some great stuff here.  We need to have a marathon meeting in which 10
> or more people do a one-liner each.. and others can critique, expand, etc.
> 
> Say, June?  Who's in?
> 
> g
> 
> _______________________________________________
> talk mailing list
> talk at lists.nycbug.org
> http://www.nycbug.org/mailman/listinfo/talk
> 





More information about the talk mailing list