-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdot_zsh.functions
88 lines (65 loc) · 2.13 KB
/
dot_zsh.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
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
#!/bin/bash
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fzfp() {
fzf --preview '[[ $(file --mime {}) =~ binary ]] && echo {} is a binary file || (bat --style=numbers --color=always {} || highlight -O ansi -l {} || coderay {} || rougify {} || cat {}) 2> /dev/null | head -500'
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# git
getBranchName() {
local bName
decodeSlash=$("pbpaste" | sed -nE 's///\//gp')
bName=$(echo "$decodeSlash" | sed -nE 's/.*\/c\/(.*)">.*<\/a>.*/\1/p')
echo "$bName" | pbcopy;
echo "$bName"
}
findBranch() {
git branch | grep "$1"
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# gh copilot alias lazy load (enable ghcs for cli)
load_gh_copilot () {
echo "🚨 GH Copilot not loaded! Loading now..."
# check if the command is available
if ! gh extension list | grep -q 'gh-copilot'; then
echo "🚨 GH Copilot not installed! Installing now..."
gh extension install github/gh-copilot
fi
# set alias to zsh
eval "$(gh copilot alias -- zsh)"
}
# wrap in ghcs to trigger load_gh_copilot upon first call
ghcs() {
unset -f ghcs
load_gh_copilot
eval "ghcs \$@"
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# switch_java_home() {
# if echo "$JAVA_HOME" | grep 'adoptopenjdk-8' > /dev/null;
# then
# unset JAVA_HOME
# # if 1.8 is being exported
# java11_path=$(/usr/libexec/java_home -v "11")
# export JAVA_HOME="$java11_path"
# echo "JAVA_HOME is changed to '$java11_path'"
# else
# unset JAVA_HOME
# # if 11 is being exported
# java8_path=$(/usr/libexec/java_home -v "1.8.0")
# export JAVA_HOME="$java8_path"
# echo "JAVA_HOME is changed to '$java8_path'"
# fi
# }
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# add_to_path_start() {
# case ":$PATH:" in
# *":$1:"*) :;; # already there
# *) export PATH="$1:$PATH";; # or PATH="$PATH:$1"
# esac
# }
# add_to_path_end() {
# case ":$PATH:" in
# *":$1:"*) :;; # already there
# *) export PATH="$PATH:$1";; # or PATH="$PATH:$1"
# esac
# }