Skip to content

Instantly share code, notes, and snippets.

@hwine
Created October 12, 2015 23:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hwine/9e4edfa939664c6c8fee to your computer and use it in GitHub Desktop.
Save hwine/9e4edfa939664c6c8fee to your computer and use it in GitHub Desktop.
Install matching bash completion script for current hg version.
#!/bin/bash
set -eu
hg_version=$(hg --version | grep version | sed 's,^.*(version ,,; s,).*,,')
hg_base_url=https://selenic.com/hg/rawfile/${hg_version}/contrib/bash_completion
tmp_file=/tmp/hg_completion.bash
cur_file=/usr/local/etc/bash_completion.d/hg
# Get requested version
curl -o ${tmp_file} ${hg_base_url}
# see if it is a change
if cmp --quiet ${tmp_file} ${cur_file}; then
echo "Already set for ${hg_version}"
else
mv ${tmp_file} ${cur_file}
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment