add: git-fire
This commit is contained in:
parent
9e230a4923
commit
557acfdfa9
3 changed files with 107 additions and 13 deletions
|
@ -18,10 +18,6 @@ alias git-update-submodules='
|
|||
alias gpg2-decrypt='function _gpg2-decrypt(){ gpg2 --output ${1%".gpg"} --decrypt $1; }; _gpg2-decrypt'
|
||||
alias gpg2-encrypt='function _gpg2-encrypt(){ gpg2 --output $1.gpg --encrypt $1; }; _gpg2-encrypt'
|
||||
|
||||
alias l='ls -CF'
|
||||
alias la='ls -a'
|
||||
alias lf='ls -I "__pycache__"'
|
||||
alias ll='ls -lh'
|
||||
alias ls='ls -Flh --color=never'
|
||||
|
||||
alias lsblk='lsblk -o +PARTLABEL -o +FSTYPE'
|
||||
|
|
|
@ -70,15 +70,6 @@ scrolling:
|
|||
# scrollback is enabled (history > 0).
|
||||
multiplier: 3
|
||||
|
||||
# Faux Scrolling
|
||||
#
|
||||
# The `faux_multiplier` setting controls the number of lines the terminal
|
||||
# should scroll when the alternate screen buffer is active. This is used
|
||||
# to allow mouse scrolling for applications like `man`.
|
||||
#
|
||||
# Specifying `0` will disable faux scrolling.
|
||||
faux_multiplier: 3
|
||||
|
||||
# Scroll to the bottom when new text is written to the terminal.
|
||||
auto_scroll: false
|
||||
|
||||
|
|
107
bin/git-fire
Executable file
107
bin/git-fire
Executable file
|
@ -0,0 +1,107 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
# The MIT License (MIT)
|
||||
|
||||
# Copyright (c) 2015 - 2019 Nimit Kalra <nimit@utexas.edu>
|
||||
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# Of this software and associated documentation files (the "Software"), to deal
|
||||
# In the Software without restriction, including without limitation the rights
|
||||
# To use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# Copies of the Software, and to permit persons to whom the Software is
|
||||
# Furnished to do so, subject to the following conditions:
|
||||
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# Copies or substantial portions of the Software.
|
||||
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
# Setup.
|
||||
VERSION="0.2.3"
|
||||
|
||||
version() {
|
||||
printf "git-fire version %s\n" "$VERSION"
|
||||
|
||||
git --version
|
||||
}
|
||||
|
||||
# Helpers.
|
||||
current_branch() {
|
||||
basename "$(git symbolic-ref HEAD)"
|
||||
}
|
||||
|
||||
current_epoch() {
|
||||
date +%s
|
||||
}
|
||||
|
||||
user_email() {
|
||||
git config user.email
|
||||
}
|
||||
|
||||
new_branch() {
|
||||
echo "fire-${1:-$(current_branch)}-$(user_email)-$(current_epoch)"
|
||||
}
|
||||
|
||||
fire() {
|
||||
initial_branch="$(current_branch)"
|
||||
|
||||
git checkout -b "$(new_branch)"
|
||||
|
||||
# cd to git root directory
|
||||
cd "$(git rev-parse --show-toplevel)"
|
||||
|
||||
git add -A
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
message="Fire! Branch $(current_branch)."
|
||||
else
|
||||
message="$*"
|
||||
fi
|
||||
|
||||
git commit -m "$message" --no-verify
|
||||
|
||||
for remote in $(git remote); do
|
||||
git push --no-verify --set-upstream "${remote}" "$(current_branch)" || true
|
||||
done
|
||||
|
||||
if [ "$(git stash list)" != '' ]; then
|
||||
for sha in $(git rev-list -g stash); do
|
||||
git push --no-verify origin "$sha":refs/heads/"$(current_branch $initial_branch)"-stash-"$sha"
|
||||
done
|
||||
fi
|
||||
|
||||
printf "\n\nLeave building!\n"
|
||||
}
|
||||
|
||||
display_help() {
|
||||
cat <<-EOF
|
||||
|
||||
usage:
|
||||
git fire [options] [COMMAND] [args]
|
||||
|
||||
commands:
|
||||
git fire Add, commit, and push to remote in case of a fire
|
||||
git fire <message> Execute git fire with <message> for commit message
|
||||
|
||||
|
||||
options:
|
||||
-V, --version Output current version of git-fire
|
||||
-h, --help Display this help information
|
||||
|
||||
EOF
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
||||
case $1 in
|
||||
-V|--version) version; exit 0 ;;
|
||||
-h|--help) display_help; exit 0 ;;
|
||||
esac
|
||||
|
||||
fire "$@"
|
Loading…
Reference in a new issue