# HG changeset patch # User Jeff Hammel # Date 1371663961 25200 # Node ID 4d5d5097686f2adf463a5be1dbc6ef2519029324 # Parent b27ea86a9c9ed091780803b629400fec0d68cb29# Parent a9d3f12105068abba0210193e3817a6b3eddc00b first commit diff -r a9d3f1210506 -r 4d5d5097686f .bash_overrides --- a/.bash_overrides Tue Jun 18 16:50:10 2013 -0700 +++ b/.bash_overrides Wed Jun 19 10:46:01 2013 -0700 @@ -103,7 +103,7 @@ then curl --location "$1" 2> /dev/null | command lsdiff else - lsdiff "$1" + command lsdiff "$@" fi } diff -r a9d3f1210506 -r 4d5d5097686f .bashrc --- a/.bashrc Tue Jun 18 16:50:10 2013 -0700 +++ b/.bashrc Wed Jun 19 10:46:01 2013 -0700 @@ -1,4 +1,8 @@ -source /etc/profile +PROFILE=/etc/profile +if [ -e "${PROFILE}" ] +then + . "${PROFILE}" +fi # Test for an interactive shell. There is no need to set anything # past this point for scp and rcp, and it's important to refrain from @@ -32,6 +36,7 @@ alias grep='grep --colour=auto' alias ls='ls --color=auto' alias random="python -c 'import sys, random; foo = sys.argv[1:]; random.shuffle(foo); print \" \".join(foo)'" +alias weekstamp="date --date=\"$((`date '+%u'`-1)) days ago\" '+%b %d'" alias wget='wget --no-check-certificate' alias xpcshell="LD_LIBRARY_PATH=${MOZOBJ}/dist/bin ${MOZOBJ}/dist/bin/xpcshell" @@ -48,7 +53,7 @@ PROMPT_COMMAND='echo -ne "\033]0;${SSH_CLIENT/*/$HOSTNAME:}${PWD/~/~}\007"' # PATHs -export PATH=~/firefox:~/bin:~/python:$PATH:/usr/sbin:/usr/games/bin +export PATH=~/firefox:~/bin:~/bin/mozilla:~/python:$PATH:/usr/sbin:/usr/games/bin export PYTHONPATH=~/python:$PYTHONPATH:~/virtualenv ### functions @@ -56,8 +61,10 @@ apply-patch() { # apply a patch # TODO: + # - rewrite in python! # - extract this general pattern as a bash "decorator" like `lsdiff` in .bash_overrides # - right now level=1; make this configurable (somehow) + if (( ! $# )) then echo "No patch supplied" @@ -281,6 +288,11 @@ mv "$NEWNAME" "$2" } +buffer() { + # temporary buffer with cat and /dev/null + cat > /dev/null +} + ### `which` commands realwhich() { @@ -421,6 +433,8 @@ echo "$HOME/web/blog/k0s/entries/public/$1" } +### + flatten() { directory=$PWD if [ "$#" == "1" ] @@ -463,6 +477,19 @@ } +rmktmp() { + +TMPDIR=~/tmp +if [ -e ${TMPDIR} ] +then + rm -rf ${TMPDIR} +fi +mkdir ${TMPDIR} +cd ${TMPDIR} +pwd + +} + ### include overrides for commands source ~/.bash_overrides diff -r a9d3f1210506 -r 4d5d5097686f .gitconfig --- a/.gitconfig Tue Jun 18 16:50:10 2013 -0700 +++ b/.gitconfig Wed Jun 19 10:46:01 2013 -0700 @@ -5,5 +5,9 @@ email = jhammel@mozilla.com [alias] branches = branch -a + branchname = git rev-parse --abbrev-ref HEAD + discard = reset HEAD --hard + patch = !git diff > ~/$(git rev-parse --abbrev-ref HEAD).diff root = rev-parse --show-toplevel st = status + up = !git pull mozilla master && git push origin master diff -r a9d3f1210506 -r 4d5d5097686f bin/example/README.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bin/example/README.txt Wed Jun 19 10:46:01 2013 -0700 @@ -0,0 +1,1 @@ +Example scripts of how to do particular things in bash diff -r a9d3f1210506 -r 4d5d5097686f bin/example/script-path.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bin/example/script-path.sh Wed Jun 19 10:46:01 2013 -0700 @@ -0,0 +1,7 @@ +#!/bin/bash + +# echoes path to this script (example) + +echo "argv[0]: $0" +path=`readlink -f $0` +echo "path: ${path}" diff -r a9d3f1210506 -r 4d5d5097686f bin/example/self-writing.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bin/example/self-writing.sh Wed Jun 19 10:46:01 2013 -0700 @@ -0,0 +1,33 @@ +#!/bin/bash + +# illustrate self-writing script (example) +# This one does something hard and replaces dynamic data with sed. +# Other solutions (magic markers, etc) are possible + +path=`readlink -f $0` +mode=`stat --format '%a' ${path}` +tmp=`tempfile --mode ${mode}` +datestamp=`date` +nonce="This script last generated at " + +# sanity check +if [[ ! -w "${path}" ]] +then + echo "You don't have write permission for script ${path}" + exit 1 +fi + +# avoiding -i for safety +sed 's/\(echo \"'"${nonce}"'\).*\"/\1'"${datestamp}"'\"/' ${path} > ${tmp} +if [[ ! -e "${tmp}" ]] +then + echo "Temporary file creation not successful" + exit 1 +fi + +# echo last and current generation times for example +echo "This script last generated at Sat Jun 8 08:52:35 PDT 2013" +echo "Now: ${datestamp}" + +# move tmpfile -> script location via exec +exec mv ${tmp} ${path} diff -r a9d3f1210506 -r 4d5d5097686f bin/hg-merge-branch.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bin/hg-merge-branch.sh Wed Jun 19 10:46:01 2013 -0700 @@ -0,0 +1,26 @@ +#!/bin/bash + +# merge a hg branch repo +# from https://wiki.mozilla.org/User:Asasaki:Cedar +# TODO: inclusion in mercurial utilities package + +if [[ "$#" != "3" ]] +then + echo "Usage: hg-merge-branch.sh scheme://hg/repository" + exit 1 +fi + +if ! hg root +then + exit 255 +fi + +# Update to latest +# the hg up -C will blow away any local changes! +#hg pull +#hg up -C -r default + +# Pull latest branch changes in +#hg pull $1 +#hg merge +#hg commit -m "Merge m-c -> cedar"