init fedit

pull/3/head
kevin zhuang 4 years ago
parent 59600ec228
commit effe266a66

@ -52,6 +52,10 @@ case "$1" in
action_command='fstat'
shift
;;
fedit)
action_command='fedit'
shift
;;
help)
usage
exit 0

@ -74,7 +74,7 @@ function get_branch() {
# e.g.$HOME/.config/nvim/init.vim
#######################################
function get_git_file() {
local header="${1:-select a file}"
local header="${1:-select tracked file}"
set_fzf_multi "$2"
/usr/bin/git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" \
ls-files --full-name --directory "${DOTBARE_TREE}" \

@ -0,0 +1,60 @@
#!/bin/bash
#
# interactive menu to select file/commit to edit
#
# @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 fedit [-h] ...\n"
echo -e "List all tracked dotfiles and edit"
echo -e "also support commit message edit\n"
echo -e "optional arguments:"
echo -e " -h\t\tshow this help message and exit"
echo -e " -m\t\tonly display modified file"
echo -e " -c\t\tedit commit message instead"
}
modified=''
commit=''
while getopts ":hmc" opt; do
case "$opt" in
m)
modified='true'
break
;;
c)
commit='true'
break
;;
h)
usage
exit 0
;;
*)
echo "Invalid option: ${OPTARG}" >&2
usage
exit 1
;;
esac
done
if [[ -n "${commit}" ]]; then
echo "commit"
elif [[ -n "${modified}" ]]; then
echo "modified"
else
selected_files=$(get_git_file "Select tracked files to edit")
echo "${selected_files}"
fi

@ -7,7 +7,7 @@
# Globals
# ${mydir}: current directory of the script
# ${search_commits}: search commits and reset commits instead of files
# #{reset_option}: git reset flag, --mixed | --soft | --hard
# ${reset_option}: git reset flag, --mixed | --soft | --hard
# ${all_files}: search all files and select a commit to reset
# ${selected_files}: selected file to unstage
# ${selected_commit}: selected commit to reset

@ -19,7 +19,7 @@ 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 "Stage, unstage, interactively\n"
echo -e "optional arguments:"
echo -e " -h\t\tshow this help message and exit"
}

Loading…
Cancel
Save