-
Notifications
You must be signed in to change notification settings - Fork 0
/
.functions
51 lines (43 loc) · 898 Bytes
/
.functions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env bash
# Test function
function t() {
if [[ "$PWD" == "$HOME" ]]; then
cd ~/Tests || exit
elif [[ -r "package.json" ]]; then
npm test "$@"
elif [[ -r "go.mod" ]]; then
go test "$@"
elif [[ -r "Gemfile" ]]; then
rake test "$@"
else
echo "test command"
fi
}
# Git clone function
function gclone() {
if ! command -v gh &>/dev/null; then
echo "gh command not found"
exit
fi
repo=$1
repo=${repo/#https:\/\/github.com\//}
dir=$2
if [[ -z $dir ]]; then
dir=${repo/\//@}
fi
gh repo clone $repo $dir
}
# Example: feature-YYYYmmdd-name
function git-feature() {
date_format=$(date -u +"%Y%m%d")
branch="feature-$date_format-$1"
git checkout -b "$branch"
}
# Open browser goto repo home page by origin remote
function git-home() {
url=$(git config remote.origin.url)
open "$url"
}
function gh-todo() {
gh todo "$@"
}