Skip to content

Instantly share code, notes, and snippets.

@kballenegger
Created September 5, 2014 18:26
Show Gist options
  • Save kballenegger/b02570f175e6b601fa60 to your computer and use it in GitHub Desktop.
Save kballenegger/b02570f175e6b601fa60 to your computer and use it in GitHub Desktop.
Ack git-ls-files wrapper script.
#!/bin/bash
function realpath { echo $(cd "$(dirname $1)"; pwd)/"$(basename $1)"; }
if git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
args=( "$@" )
# unset last arg
#unset args[$(echo ${#args[@]}-1 | bc)]
unset args[${#args[@]}-1]
# cd into root dir
cd "$(git rev-parse --git-dir)"; cd ..
# build new args with file list
new_args=("${args[@]}" "$(git ls-files -oc --exclude-standard)")
# execute
echo ack ${new_args[@]}
else
echo ack $@
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment