update help and var name

pull/3/head
kevin zhuang 4 years ago
parent 1f03bd36fb
commit 0b260925fe

@ -5,9 +5,9 @@
# @params
# Globals
# ${mydir}: string, directory of the executing script, used for sourcing helpers
# ${action_command}: string, determine which script to call
# ${action_command}: string, determine which script to call
# Arguments
# action_command: sub commands dotbare should run
# action_command: sub commands dotbare should run
# General git command: log, status etc
# dotbare specific commands: fadd | frm | fpop | freset | fcheckout | help
# option flags:

@ -9,6 +9,7 @@
# ${DOTBARE_KEY}: string, defualt key bindings
# ${FZF_DEFAULT_OPTS}: string, update FZF_DEFAULT_OPTS to reflect dotbare changes
# ${DOTBARE_FZF_DEFAULT_OPTS}: string, user custom setting for dotbare
# ${EDITOR}: default editor to use
DOTBARE_DIR="${DOTBARE_DIR:-$HOME/.cfg/}"
DOTBARE_TREE="${DOTBARE_TREE:-$HOME}"

@ -7,7 +7,11 @@
# ${mydir}: string, current directory of the executing script
# ${new_file}: new file path to stage
# ${new_folder}: new folder to stage
# ${selected_files}: changed file to stage
# ${selected_files}: modified file to stage
# Arguments
# -h: show help message
# -f: select a file in PWD to stage
# -d: select a directory in PWD to stage
set -e
set -f
@ -27,6 +31,11 @@ function usage() {
echo -e " -d\t\tselect a entire folder to stage"
}
#######################################
# stage file
# Arguments:
# $1: files to stage
#######################################
function stage_file() {
local file=$1
if [[ -z "${file}" ]]

@ -1,22 +1,26 @@
#!/bin/bash
#
# checkout files/commits/branches using fzf
# checkout files/commit/branches using fzf
#
# @params
# Globals
# ${mydir}: current directory of the script, used for imports
# ${all_files}: search all tracked files instead of just the modified files
# and then select a specific commit to checkout against
# ${branch}: checkout branch
# ${commit}: checkout commit
# ${selected_branch}: selected_branch to switch
# ${selected_files}: selected_files to checkout to the version in HEAD
# ${selected_commit}: selected commit to checkout
# ${confirm}: confirm status of the user
# Arguments
# -h: show help message
# -a: search all files instead of just the modified files
# -b: search branch and checkout branch
# -c: search commits and checkout commits
# -c: search commit and checkout commit
set -e
set -f
mydir="${0%/*}"
source "${mydir}"/../helper/set_variable.sh
@ -25,7 +29,7 @@ source "${mydir}"/../helper/git_query.sh
function usage() {
echo -e "Usage: dotbare fcheckout [-h] [-a] [-b] [-c] ...\n"
echo -e "Checkout files/commits/branch using fzf"
echo -e "Checkout files/commit/branch using fzf"
echo -e "By default: checkout files back to HEAD (Reset changes back to HEAD)\n"
echo -e "optional arguments:"
echo -e " -h\t\tshow this help message and exit"
@ -36,9 +40,9 @@ function usage() {
all_files=""
branch=""
commits=""
commit=""
while getopts ":habcC" opt
while getopts ":habc" opt
do
case "$opt" in
a)
@ -50,7 +54,7 @@ do
break
;;
c)
commits='true'
commit='true'
break
;;
h)
@ -71,8 +75,8 @@ if [[ -n "${branch}" ]]; then
[[ -z "${selected_branch}" ]] && exit 0
/usr/bin/git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" checkout "${selected_branch}"
exit 0
elif [[ -n "${commits}" ]]; then
# checkout commits
elif [[ -n "${commit}" ]]; then
# checkout commit
selected_commit=$(get_commit 'Select a commit to checkout')
[[ -z "${selected_commit}" ]] && exit 0
/usr/bin/git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" checkout "${selected_commit}"

@ -4,9 +4,15 @@
#
# @params
# Globals
# None
# ${mydir}: current directory of the script
# ${modified}: select modified file only
# ${commit}: rename commit
# ${selected_commit}: selected commit to edit
# ${selected_files}: selected file to edit
# Arguments
# None
# -m: display modified file only
# -c: edit commit using interactive rebase
# -h: show helpe message and exit
set -e
set -f
@ -22,7 +28,7 @@ function usage() {
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"
echo -e " -c\t\tedit commit using interactive rebase instead"
}
modified=''

@ -6,12 +6,18 @@
# @params
# Globals
# ${mydir}: current directory of the script
# ${search_commits}: search commits and reset commits instead of files
# ${reset_commit}: search commits and reset selected commit instead of files
# ${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
# ${selected_branch}: selected branch to reset
# ${confirm}: confirmation status of the user
# Arguments
# -h: show help message and quit
# -a: select files and select a commit to reset the fiel back to selected commit
# -c: reset commit
# -S: use --soft flag
# -H: use --hard flag
set -e
set -f
@ -33,7 +39,7 @@ function usage() {
echo -e " -H\t\treset commit using --hard flag, reset HEAD to certain commit dicard all changes from the working tree"
}
search_commits=""
reset_commit=""
reset_option="--mixed"
all_files=""
@ -44,7 +50,7 @@ do
all_files="true"
;;
c)
search_commits="true"
reset_commit="true"
;;
S)
reset_option="--soft"
@ -64,7 +70,7 @@ do
esac
done
if [[ -n "${search_commits}" ]]; then
if [[ -n "${reset_commit}" ]]; then
selected_commit=$(get_commit)
[[ -z "${selected_commit}" ]] && exit 0
confirm=$(get_confirmation "Reset HEAD to ${selected_commit} ${reset_option}?")

Loading…
Cancel
Save