Skip to content

Commit 39cef9e

Browse files
committed
feat: add support for linux xdg-open
1 parent 8371d53 commit 39cef9e

File tree

4 files changed

+23
-4
lines changed

4 files changed

+23
-4
lines changed

git-open-commit

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22

33
set -e
44

5+
# import dependency
6+
parentPath=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
7+
. "$parentPath/os-open"
8+
59
commitSHA=$1
610
test -z "$commitSHA" && echo "Please provide SHA string of a commit." 1>&2 && exit 1
711

812
gitUserAndProject="$(git config --get remote.origin.url | cut -d : -f 2 | cut -d . -f 1)"
913

10-
open "https://github.com/$gitUserAndProject/commit/$commitSHA"
14+
$OS_OPEN "https://github.com/$gitUserAndProject/commit/$commitSHA"

git-open-file

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22

33
set -e
44

5+
# import dependency
6+
parentPath=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
7+
. "$parentPath/os-open"
8+
59
filePath=$1
610
test -z "$filePath" && echo "Please provide file path to open." 1>&2 && exit 1
711

812
gitUserAndProject="$(git config --get remote.origin.url | cut -d : -f 2 | cut -d . -f 1)"
913
mainBranch="$(cat .git/refs/remotes/origin/HEAD | cut -d '/' -f 4)"
1014

11-
open "https://github.com/$gitUserAndProject/blob/$mainBranch/$filePath"
15+
$OS_OPEN "https://github.com/$gitUserAndProject/blob/$mainBranch/$filePath"

git-start-branch

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
set -e
44

55
# Check if params are enough to go ahead.
66
baseBranch=$1
77
featureBranch=$2
8-
test -z "$baseBranch" && echo "Please provide the source base branch." 1>&2 && exit 1
8+
test -z "$baseBranch" && echo "Please provide the base and feature branch." 1>&2 && exit 1
99
test -z "$featureBranch" && echo "Please provide the name for feature branch." 1>&2 && exit 1
1010

1111
# Find which is your current branch

os-open

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Found OS open utility and define it as OS_OPEN variable
2+
LINUX_OPEN="$(command -v xdg-open)"
3+
OSX_OPEN="$(command -v open)"
4+
if [ -x $LINUX_OPEN ]; then
5+
OS_OPEN=$LINUX_OPEN
6+
elif [ -x $OSX_OPEN ]; then
7+
OS_OPEN=$OSX_OPEN
8+
else
9+
echo 'No open utility found'
10+
exit 1
11+
fi

0 commit comments

Comments
 (0)