Added the ability to browse GitHub files.
This commit is contained in:
parent
304530d990
commit
1a3940b9a3
@ -8,11 +8,12 @@
|
|||||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
||||||
local state remotes remote branches ret=1
|
local state remotes remote branches files ret=1
|
||||||
|
|
||||||
_arguments -C -s -S \
|
_arguments -C -s -S \
|
||||||
'1::args:->remote' \
|
'1::args:->remote' \
|
||||||
'2::args:->branch' && ret=0
|
'2::args:->branch' \
|
||||||
|
'3::args:->file' && ret=0
|
||||||
|
|
||||||
case "$state" in
|
case "$state" in
|
||||||
(remote)
|
(remote)
|
||||||
@ -33,6 +34,10 @@ case "$state" in
|
|||||||
))
|
))
|
||||||
_describe -t branch 'branches' branches && ret=0
|
_describe -t branch 'branches' branches && ret=0
|
||||||
;;
|
;;
|
||||||
|
(file)
|
||||||
|
files=(${(0)"$(_call_program files git ls-files -z --exclude-standard 2>/dev/null)"})
|
||||||
|
_wanted file expl 'file' _multi_parts - / files && ret=0
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
return $ret
|
return $ret
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
||||||
local remote branches branch current_branch url
|
local remote branches branch current_branch file url
|
||||||
|
|
||||||
remote="${1:-origin}"
|
remote="${1:-origin}"
|
||||||
url=$(
|
url=$(
|
||||||
@ -18,6 +18,7 @@ branches=($(
|
|||||||
))
|
))
|
||||||
current_branch="$(git-branch)"
|
current_branch="$(git-branch)"
|
||||||
branch="${2:-master}"
|
branch="${2:-master}"
|
||||||
|
file="$3"
|
||||||
|
|
||||||
if [[ -z "$2" ]]; then
|
if [[ -z "$2" ]]; then
|
||||||
if (( $branches[(I)$current_branch] != 0 )); then
|
if (( $branches[(I)$current_branch] != 0 )); then
|
||||||
@ -28,7 +29,7 @@ if [[ -z "$2" ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "$url" ]]; then
|
if [[ -n "$url" ]]; then
|
||||||
url="${url}/tree/${branch}"
|
url="${url}/tree/${branch}/${file}"
|
||||||
|
|
||||||
if (( $+commands[$BROWSER] )); then
|
if (( $+commands[$BROWSER] )); then
|
||||||
"$BROWSER" "$url"
|
"$BROWSER" "$url"
|
||||||
|
Reference in New Issue
Block a user