2
0
mirror of https://github.com/kazhala/dotbare synced 2024-11-02 09:40:27 +00:00
dotbare/scripts/fstat

48 lines
1.2 KiB
Plaintext
Raw Normal View History

2020-04-21 05:25:02 +00:00
#!/bin/bash
#
# interactive git status menu
2020-04-21 06:07:23 +00:00
# allow staging ustaging actions
2020-04-21 05:25:02 +00:00
#
# @params
# Globals
# None
# Arguments
# None
set -e
set -f
mydir="${0%/*}"
source "${mydir}"/../helper/set_variable.sh
source "${mydir}"/../helper/git_query.sh
function usage() {
echo -e "Usage: dotbare fstat [-h] ...\n"
echo -e "Display interactive git status menu"
echo -e "Stage, unstage, edit file interactively\n"
echo -e "optional arguments:"
echo -e " -h\t\tshow this help message and exit"
}
while true; do
2020-04-21 06:42:00 +00:00
selected_files=$(get_modified_file "select a file" "all" "raw")
2020-04-21 05:25:02 +00:00
[[ -z "${selected_files}" ]] && break
2020-04-21 06:42:00 +00:00
stage_file=$(echo "${selected_files}" | awk '{
if ($0 ~ /^[A-Za-z][A-Za-z].*$/) {
print "stage"
} else if ($0 ~ /^[ \t].*$/) {
print "stage"
}
}')
selected_files=$(echo "${selected_files}" | awk -v home="${DOTBARE_TREE}" '{
print home "/" $2
}')
if [[ -z "${stage_file}" ]]; then
2020-04-21 06:07:23 +00:00
# shellcheck disable=SC2086
2020-04-21 06:42:00 +00:00
/usr/bin/git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" reset --quiet HEAD ${selected_files}
2020-04-21 06:07:23 +00:00
else
# shellcheck disable=SC2086
2020-04-21 06:42:00 +00:00
/usr/bin/git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" add ${selected_files}
2020-04-21 06:07:23 +00:00
fi
2020-04-21 05:25:02 +00:00
done