-
Notifications
You must be signed in to change notification settings - Fork 626
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature request]: Use tig as commit picker #575
Comments
@kgraefe you can bind a key to do that. Adding the following to
|
Yes, I know. But I have multiple use cases where I need a Git ID and I don't want to create (and remember) a binding for each of them. The Right now I often find me opening |
@kgraefe you can replace the command for rebase here with your script.
|
Sure. Still that does not help me with what I want to achieve (please see above). |
I managed to write a wrapper around Find attached my wrapper script
#!/bin/bash
set -e
CONFIG=$(mktemp)
trap "rm -f '$CONFIG'" EXIT
# Prepare config file
if [ ! -z "$TIGRC_USER" ]; then
echo "source $TIGRC_USER" >> $CONFIG
elif [ -f "$HOME/.tigrc" ]; then
echo "source $HOME/.tigrc" >> $CONFIG
fi
# Bind Enter to print commit ID and exit
echo 'bind main <Enter> <sh -c "echo %(commit) >&2"' >> $CONFIG
# Run tig
export TIGRC_USER=$CONFIG
commit=$(tig "$@" 3>&2 2>&1 1>&3-)
# Check returned value for valid commit ID
if ! echo -n "$commit" | grep -iqE '^[0-9a-f]{40}$'; then
exit 1
fi
echo "$commit" |
We can add the script to the |
Sure. I will do some clean-ups and documentation as soon as I can find the time and make a PR after that. Can you assign me to this ticket? (I can't, apparently) |
Done |
I'd like to use the
tig
main view for selecting a specific commit and use its commit ID as a parameter for a script, e.g.:git rebase -i $(tig select)
.The text was updated successfully, but these errors were encountered: