Mercurial > dotfiles
view .shell.d/50.hg_functions.sh @ 377:117e3c11d953
zprofile: introduce zprofile use
El Capitan (OS X 10.11) introduces a system-level /etc/zprofile which
uses a path_helper thing to mangle $PATH. Unfortunately, the way
path_helper works, it forces /usr/local/bin and /usr/bin to the
*start* of the PATH variable, which means that any PATH mutations I
want have to run after /etc/zprofile calls path_helper. As such, move
my path insertions into .zprofile{,-machine} rather than
.zshenv{,-machine} so that I can still ensure my path entries are at
the start of PATH rather than the end. This works because:
> Commands are then read from $ZDOTDIR/.zshenv. If the shell is a
> login shell, commands are read from /etc/zprofile and then
> $ZDOTDIR/.zprofile. Then, if the shell is interactive, commands
> are read from /etc/zshrc and then $ZDOTDIR/.zshrc. Finally, if the
> shell is a login shell, /etc/zlogin and $ZDOTDIR/.zlogin are read.
This means that non-login shells no longer pick up my custom PATH
entries, but as I only use OS X as a desktop OS that seems like a
workable tradeoff for now.
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Sun, 31 Jan 2016 20:46:29 -0500 |
parents | fc89d315942f |
children |
line wrap: on
line source
## hg_functions # various hg utility functions function mq () { ( wcroot ; hg -R .hg/patches $@ ) } function mq_snapshot () { mq ci -m "Applied on $(hg log -r qparent --template '{node|short}\n')" } alias mq-snapshot=mq_snapshot function hg_rebase_all () { hg sum | egrep 'commit: .*\(clean\)$' || (echo 'abort: wc not clean' ; return 1) || return 1 if [ "x$1" = "x" ] ; then echo 'abort: give destination for rebase' return 2 fi if [ "$1" = "tip" ] ; then echo 'abort: tip is essentially never what you mean here' return 2 fi marks=$(hg book | sed 's/^ \*/ /' | awk '{ print $1 }') if [ "$marks" = "no bookmarks set" ] ; then echo "no bookmarks set, nothing to rebase" fi for b in $(echo $marks) ; do echo "About to rebase $b" out=$(hg rebase -d "$1" -b "$b") code=$? echo $out | grep "nothing to rebase" if [ $? = 0 ] ; then echo 'moving on' else if [ $code -ne 0 ] ; then echo "rebase exited with status $out" return 3 fi fi done } alias hg-rebase-all=hg_rebase_all function hgsvnmergebranch() { local targetrev local striprev targetrev=$(hg id | cut -d ' ' -f 1) hg merge $1 hg ci -m "Merging $1" striprev=$(hg id | cut -d ' ' -f 1) hg co $targetrev hg diff -r$targetrev:$striprev | hg import - -m "Merged branch $1." hg strip $striprev } alias hg-svn-merge-branch=hgsvnmergebranch function hgsvnrebaseall() { for b in `hg log -u 'Augie Fackler <durin42@gmail.com>' --template '{branches}\n' | sort | uniq` do echo "rebase $b" hg co $b if [[ "$?" != "0" ]] ; then echo "abort: could not checkout $b" return fi hg parent --svn > /dev/null if [[ "$?" == "0" ]] ; then hg rebase --svn || return else echo "Skip $b since it has a merge." fi done } alias hg-svn-rebase-all=hgsvnrebaseall function hgamend() { hg qimport -r . && hg qref && hg qfin qtip } alias hg-amend=hgamend function hg_verify_all() { for x in $(find . -name '.hg') ; do y=$(dirname $x) echo $y hg verify -R $y done } function hgsvnmkbranch() { local upstream upstream=$(hg paths default | sed 's%/*$%%') local branchname if [ "x$1" = "x" ] ; then echo 'Must provide new branch name.' return 1 fi local d=`hg svn info | grep URL | sed 's/.*://'` local br=`echo $d | awk '{ if ( index($1, "trunk") ) { print "trunk" } else { x = index($1, "branches") ; if ( x != 0 ) { sub(".*/branches/", ""); sub("/.*", ""); print $0 } } }'` branchname=$br echo svn cp $upstream/$branchname $upstream/branches/$1 } alias hg-svn-mkbranch=hgsvnmkbranch