Skip to content

Commit e2c67a8

Browse files
author
Bhavi Dhingra
committed
fix(custom-git-explorer): ctrl-d operation for more details
1 parent 0c46ba1 commit e2c67a8

File tree

7 files changed

+27
-15
lines changed

7 files changed

+27
-15
lines changed

.gitcommitscopes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
ask
2+
custom-git-explorer
23
gadd
34
gbranchcreate
45
gcommit

cmd/custom-git-explorer

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function get_verb() {
3030
--info=hidden\
3131
--preview "source $__CUSTOM_GIT_UTIL/fzf_previews/custom-git-explorer/__verb_preview;
3232
__verb_preview {}")"
33-
echo "${verb}"
33+
echo "${verb/*. /}"
3434
}
3535

3636
# Usage: get_noun "add"
@@ -39,13 +39,13 @@ function get_noun() {
3939
local verb="${1}"
4040
local NOUN_ARR=()
4141
__get_nouns "${verb}"
42-
local nounHeader="$(__noun_header "${verb/*. /}")"
42+
local nounHeader="$(__noun_header "${verb}")"
4343
local noun="$(printf "%s\n" "${NOUN_ARR[@]}" |\
4444
fzf --height=10% --preview-window right:65%\
4545
--header "${nounHeader}"\
4646
--info=hidden\
4747
--bind "enter:ignore"\
48-
--bind "ctrl-d:execute-silent(source $__CUSTOM_GIT_UTIL/custom-git-explorer/__open_web_page; __open_web_page ${verb} {} &)"\
48+
--bind "ctrl-d:execute(source $__CUSTOM_GIT_UTIL/custom-git-explorer/__open_web_page; __open_web_page ${verb} {} &)"\
4949
--preview "source $__CUSTOM_GIT_UTIL/fzf_previews/custom-git-explorer/__noun_preview;
5050
__noun_preview ${verb/*. /} {}")"
5151
echo "${noun}"

util/__isgitrepo

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
3+
function __isgitrepo() {
4+
5+
if git rev-parse --git-dir > /dev/null 2>&1; then
6+
# This is a valid git repository.
7+
echo true
8+
else
9+
echo false
10+
fi
11+
}

util/custom-git-explorer/__get_nouns

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ function __get_nouns() {
1010

1111
local verb="${1}"
1212
case "${verb}" in
13-
"1. show/view")
13+
"show/view")
1414
NOUN_ARR=("1. status" "2. uncommitted changes" "3. commit logs/history")
1515
;;
16-
"2. add")
16+
"add")
1717
NOUN_ARR=("1. new changes")
1818
;;
19-
"3. restore")
19+
"restore")
2020
NOUN_ARR=("1. staged changes" "2. unstaged changes")
2121
;;
2222
*)
23-
__print_err "[__noun_preview] verb: ${verb}, noun: unknown"
23+
__print_err "[__get_nouns] unknown verb: ${verb}"
2424
;;
2525
esac
2626
}

util/custom-git-explorer/__get_url

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function __get_url() {
2424
url="https://bhavidhingra.github.io/just-my-docs/explorer/show/commit-logs"
2525
;;
2626
*)
27-
__print_err "[__get_url] verb: ${verb}, noun: unknown"
27+
__print_err "[__get_url] verb: ${verb}, unknown noun: ${noun}"
2828
;;
2929
esac
3030
;;
@@ -34,7 +34,7 @@ function __get_url() {
3434
url="https://bhavidhingra.github.io/just-my-docs/explorer/add/new-changes"
3535
;;
3636
*)
37-
__print_err "[__get_url] verb: ${verb}, noun: unknown"
37+
__print_err "[__get_url] verb: ${verb}, unknown noun: ${noun}"
3838
;;
3939
esac
4040
;;
@@ -47,12 +47,12 @@ function __get_url() {
4747
url="https://bhavidhingra.github.io/just-my-docs/explorer/restore/unstaged-changes"
4848
;;
4949
*)
50-
__print_err "[__get_url] verb: ${verb}, noun: unknown"
50+
__print_err "[__get_url] verb: ${verb}, unknown noun: ${noun}"
5151
;;
5252
esac
5353
;;
5454
*)
55-
__print_err "[__get_url] unknown verb"
55+
__print_err "[__get_url] unknown verb: ${verb}"
5656
;;
5757
esac
5858

util/custom-git-explorer/__open_web_page

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55

66
source "$__CUSTOM_GIT_UTIL"/custom-git-explorer/__get_url
77

8-
# Usage: __open_web_page "add" "new changes"
8+
# Usage: __open_web_page "add" "1. new changes"
99
function __open_web_page() {
1010

1111
local verb="${1}"
12-
local noun="${2}"
12+
local noun="${2/*. /}"
1313
local url="$(__get_url "${verb}" "${noun}")"
1414
[ -z "${url}" ] && return
1515

util/fzf_previews/custom-git-explorer/__verb_preview

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ source "${__CUSTOM_CONSOLE_UTIL}"/__println_as
88
# Usage: __verb_preview "add"
99
function __verb_preview() {
1010

11-
local verb="${1}"
11+
local verb="${1/*. /}"
1212
local NOUN_ARR=()
1313
__get_nouns "${verb}"
14-
__println_as bold "${verb/*. /}:- "
14+
__println_as bold "${verb}:- "
1515
echo
1616
printf "%s\n" "${NOUN_ARR[@]}"
1717
}

0 commit comments

Comments
 (0)