-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.myzsh_funcs
115 lines (91 loc) · 3.05 KB
/
.myzsh_funcs
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# vim: syntax=zsh:
function isLinux() {
[[ $(uname) == 'Linux' ]];
}
function isMac() {
[[ $(uname) == 'Darwin' ]];
}
function daru(){
/home/linuxbrew/.linuxbrew/bin/$1 ${@:2}
}
## LINUX
# function download(){
# URL=$( xclip -selection c -o )
# #curl "$URL" -o /dev/null 2> /dev/null
# if [ $? -eq 0 ]; then
# aria2c -x16 "$URL" --seed-time=0 $@
# else
# print -P "%F{red}Not a valid URL!%f"
# return 1
# fi;
# }
function download(){
URL=$( pbpaste )
#curl "$URL" -o /dev/null 2> /dev/null
if [ $? -eq 0 ]; then
aria2c -x16 "$URL" --seed-time=0 $@
else
print -P "%F{red}Not a valid URL!%f"
return 1
fi;
}
function serve(){
servefile "$(ls | fzy)";
}
##Dynamically Update prompt
#TMOUT=5
#TRAPALRM() {
# zle reset-prompt
#}
# This is for the mi lights
function yeet() { (workon life && yeecli $@ && deactivate ) }
function adb-mirror() {
ADB=$HOME/Documents/tools/platform-tools_r31.0.3-linux/platform-tools/adb && $ADB connect 192.168.1.8:$1 && ADB=$ADB scrcpy
}
function teleconnect() {
telepresence_context_switch="$(kubectx | fzf)"
if [[ ! -z "$telepresence_context_switch" ]]; then
telepresence quit && telepresence connect --context "${telepresence_context_switch}"
fi;
}
function linguist() {
_linguist_source_location=$1
docker run -v "${_linguist_source_location:-$PWD}":/code:ro --rm github-linguist github-linguist /code
}
function get_docker_host() {
echo "$(docker context inspect $(docker context show) | jq -r '.[].Endpoints.docker.Host')";
}
# https://github.com/nektos/act/wiki/Custom-container-engine
function act() {
DOCKER_HOST="$(get_docker_host)" \
gh act $@;
}
function ssh-ec2() {
if [[ -z $2 ]]; then
echo 'You must specify the instance user and instance name!'
return 1
fi
name=$2
instance=$(aws ec2 describe-instances --output=text --query 'Reservations[*].Instances[*].[InstanceId]' --filters "Name=tag:Name,Values=$name")
if [[ -z $instance ]]; then
echo "Instance $name not found!"
return 1
fi
# aws-ssm-ec2-proxy-command.sh will take care of the rest
ssh "$1@$instance";
}
function for_all_gomod() {
GNU_FIND_CMD='find'
isMac && GNU_FIND_CMD='gfind'
$GNU_FIND_CMD -name go.mod -exec zsh -c 'cd $(dirname {}) && echo {} && '"$*" \;
}
function generate_commit_message() {
DIFF_FILE="/tmp/staged.diff"
CMD_FILE="/tmp/cmd.diff"
CURRENT_JB_IDE=$(echo -n $__CFBundleIdentifier | rev | tr '[:upper:]' '[:lower:]' | cut -d'.' -f1 | rev)
git diff --staged > $DIFF_FILE && \
echo "// Prompt: generate a good and thorough commit message using the conventional commit format for the given file, the message can have a body in bullet points also following the conventional commit format. The total body should be less than $(bc -e "$(cat $DIFF_FILE| wc -l) * 1.5 /100") lines. Don't be too specific, just give a general idea of what the changes are." > $CMD_FILE && \
cat $DIFF_FILE >> $CMD_FILE && \
(echo -n "Use prompt from the top of the file" |pbcopy) && \
$( ( echo $CURRENT_JB_IDE && \ls "$(dirname "$(which webstorm)")" ) | fzf) $CMD_FILE
}