Git Sparse Checkout Exclude

To exclude a directory, first include everything (e.g. /*), then exclude the specific folder or file:

uhleeka@uhleeka.local /cygdrive/c/projects/test (master)
$ git config core.sparsecheckout true

uhleeka@uhleeka.local /cygdrive/c/projects/test (master)
$ echo '/*' > .git/info/sparse-checkout

uhleeka@uhleeka.local /cygdrive/c/projects/test (master)
$ echo '!a_directory_i_want_to_exclude/' >> .git/info/sparse-checkout

uhleeka@uhleeka.local /cygdrive/c/projects/test (master)
$ git read-tree -m -u HEAD

This works with git 2.1.4

$ git --version
git version 2.1.4
Filed Under: Git | Tagged:

Bash Setup

Base:

#green (local)
echo "export PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$ '" >> ~/.bash_profile
#cyan (remote)
echo "export PS1='\[\e]0;\w\a\]\n\[\e[36m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$ '" >> ~/.bash_profile
#red (root)
echo "export PS1='\[\e]0;\w\a\]\n\[\e[31m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$ '" >> ~/.bash_profile

echo "" >> ~/.bash_profile

echo "export HISTSIZE=50000" >> ~/.bash_profile
echo "export HISTFILESIZE=50000" >> ~/.bash_profile

echo "" >> ~/.bash_profile

echo "alias ls='ls -al --color=auto'" >> ~/.bash_profile
echo "alias grep='grep --color=auto'" >> ~/.bash_profile
echo "alias sudo='sudo '" >> ~/.bash_profile
echo "alias vi='vim'" >> ~/.bash_profile

source ~/.bash_profile

curl -o ~/.vimrc http://amix.dk/vim/vimrc.txt

Git:

echo "" >> ~/.bash_profile

echo "function ps1_git_branch {" >> ~/.bash_profile
echo "    git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \(\1\)/';" >> ~/.bash_profile
echo "}" >> ~/.bash_profile
echo "export PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\$(ps1_git_branch)\[\e[0m\]\n\$ '" >> ~/.bash_profile

echo "" >> ~/.bash_profile

echo "export HISTSIZE=50000" >> ~/.bash_profile
echo "export HISTFILESIZE=50000" >> ~/.bash_profile

echo "" >> ~/.bash_profile

echo "alias ls='ls -al --color=auto'" >> ~/.bash_profile
echo "alias grep='grep --color=auto'" >> ~/.bash_profile
echo "alias sudo='sudo '" >> ~/.bash_profile
echo "alias vi='vim'" >> ~/.bash_profile
echo "alias gitlog='git log --graph --pretty=format:'\''%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'\'' --abbrev-commit --date=relative'" >> ~/.bash_profile

git config --global push.default simple
git config --global color.ui auto

source ~/.bash_profile

curl -o ~/.vimrc http://amix.dk/vim/vimrc.txt

PerformancePoint Dashboard Render Callback

Doing some JIT branding on a SharePoint 2010 site with bootstrap v2, I needed a way to determine when the PerformancePoint elements on a dashboard had finished loading. PerformancePoint has a problem (or maybe it’s my problem) calculating the width of its components with regard to bootstrap; I fooled it by giving the content area extra margin-left (67px in my case), and then taking it away once all PerformancePoint elements are loaded:

<script type="text/javascript">
    var NotifyBrowserOfAsyncUpdateTimeout = false;

    function NotifyBrowserOfAsyncUpdate(elem) {
        window.console && window.console.log('NotifyBrowserOfAsyncUpdate');
        if (NotifyBrowserOfAsyncUpdateTimeout) {
            clearTimeout(NotifyBrowserOfAsyncUpdateTimeout);
        }
        NotifyBrowserOfAsyncUpdateTimeout = setTimeout(function() {
            // do some stuff
            jQuery('#MSO_ContentTable').css('margin-left', '0');
            window.console && window.console.log('NotifyBrowserOfAsyncUpdateTimeout');
        }, 100);
    }
</script>

I added in the setTimeout/clearTimeout with a nominal 100ms duration, but it probably is not necessary; given some very light testing, by the time the first callback hits, PerformancePoint has correctly calculated the width of its components.

Credit: http://stackoverflow.com/questions/3372565/performancepoint-sharepoint-2010-and-jquery

Add git branch to a bash prompt

Add the following code to ~/.bash_profile or ~/.bashrc.

function ps1_git_branch {
    git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \(\1\)/'
}

export PS1="\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\$(ps1_git_branch)\[\e[0m\]\n\$ "

When in a folder that contains a .git repository, the current branch will show up in parenthesis.

uhleeka@uhleeka.local /cygdrive/c/projects/test (master)
$

Looking for something more complicated? Check out richardhansen’s https://github.com/git/…/git-prompt.sh contribution.