#!/bin/bash # # interactive git status menu # allow staging ustaging actions # # @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 selected_files=$(get_modified_file "select a file" "all" "raw") [[ -z "${selected_files}" ]] && break 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 # shellcheck disable=SC2086 /usr/bin/git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" reset --quiet HEAD ${selected_files} else # shellcheck disable=SC2086 /usr/bin/git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" add ${selected_files} fi done