-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.sh
94 lines (78 loc) · 2.25 KB
/
functions.sh
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
function platform::is_linux() {
[[ $(uname -s) == "Linux" ]]
}
function platform::is_wsl() {
grep -qEi "(Microsoft|WSL|microsoft)" /proc/version &>/dev/null
}
function platform::is_macos() {
[[ $(uname -s) == "Darwin" ]]
}
function cdd() {
cd "$(ls -d -- */ | fzf)" || echo "Invalid directory"
}
function abs_path() {
echo "$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
}
function jira() {
open -a "Google Chrome" "${JIRA_PROJECT_URL}/${1}"
}
function force-push-monoenv() {
if [ $# -ne 1 ]; then
echo "usage: push-monoenv <environment>"
return 1
fi
ENVIRONMENT=$1
BRANCH=$(git rev-parse --abbrev-ref HEAD)
git fetch -p && git branch -f $ENVIRONMENT HEAD && git checkout $ENVIRONMENT &&
git commit --allow-empty -m "[SKIP_MANUAL]" && git push --force origin
$ENVIRONMENT && git checkout $BRANCH
}
function merge-to-monoenv() {
if [ $# -ne 1 ]; then
echo "usage: merge-to-monoenv <environment>"
return -1
fi
ENVIRONMENT=$1
BRANCH=$(git rev-parse --abbrev-ref HEAD)
git checkout $ENVIRONMENT && git reset --hard origin/$ENVIRONMENT && git merge $BRANCH && git commit --allow-empty -m "[SKIP_MANUAL]" && git push origin $ENVIRONMENT
git checkout $BRANCH
}
function compare-branches() {
"$DOTFILES_PATH/scripts/git/compare-branches.sh" "$@"
}
function git-commit() {
"$DOTFILES_PATH/scripts/git/commit-no-sign.sh" "$@"
}
function pretty-diff() {
"$DOTFILES_PATH/scripts/git/pretty-diff.sh"
}
function pretty-log() {
"$DOTFILES_PATH/scripts/git/pretty-log.sh"
}
function generate-uuid() {
uuid=$(uuidgen | tr '[:upper:]' '[:lower:]')
if platform::is_macos; then
echo -n $uuid | pbcopy
osascript -e 'display notification "'"$uuid"'" with title "UUID copied to the clipboard"'
elif platform::is_wsl; then
echo -n $uuid | clip.exe
else
echo -n $uuid | xclip -sel clipboard
notify-send "UUID copied to the clipboard"
fi
}
function monoenv_git_refresh() {
MONOENVS=( apache tuculca rockola espiral spook barraca puzzle )
for MONOENV in "${MONOENVS[@]}"; do
git checkout $MONOENV
git reset --hard origin/master
git commit --allow-empty -m "[SKIP_MANUAL]"
git push -f origin $MONOENV
done
}
function timestamp-to-date() {
"$DOTFILES_PATH/scripts/utils/timestamp_to_date.sh"
}
function command_exists() {
type "$1" >/dev/null 2>&1
}