-
Notifications
You must be signed in to change notification settings - Fork 1
/
.shrc
110 lines (81 loc) · 2.26 KB
/
.shrc
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
#!/bin/sh
alias ..="cd ../"
alias ll='ls -GlA'
alias l='ls -Gl'
# Always open files in vertical split mode
alias vi='vim -O'
alias vimrc="vim $HOME/.vimrc"
if [[ "$OSTYPE" == "linux-gnu" ]]; then
# Linux
# only on linux -- OSX will throw an error if I pass the --color=auto
alias ls='ls --color=auto'
fi
export PATH="$PATH:/opt/homebrew/bin:$HOME/bin:$HOME/node_bin/node_modules/.bin:$HOME/.config/yarn/global/node_modules/.bin"
export EDITOR="vim"
export JAVA_HOME="/usr/bin/java"
ENV_FILE=$HOME/.env
if [ -f "$ENV_FILE" ]; then
source "$ENV_FILE"
fi
export NVM_DIR="$HOME/.nvm"
nvm_file="$(brew --prefix nvm)/nvm.sh"
if [ -f $nvm_file ]; then
. $nvm_file
else
echo "Unable to source nvm.sh from $nvm_file"
fi
# Change directory to the repository root
export cdr() {
cd $(git rev-parse --show-toplevel)
}
export rquery() {
rush query -q $1 | tr -d '"'
}
export rush_project_names() {
rquery ".projects[] | .packageName" | tr -d '@hz/'
}
export rush_project_folders() {
if [ -z $1 ]; then
rquery ".projects[] | .projectFolder"
exit
fi
rquery "( .projects[] | select(.packageName == \"@hz/$1\") ).projectFolder"
}
export pkg() {
if [ -z $1 ]; then
echo "Package not found"
exit 1
fi
cd $(rush_project_folders $1)
}
export rsearch() {
dirs=$(rush_project_folders)
while IFS= read -r dir; do
if [ -d "$dir/src" ]; then
grep -rl "$1" "$dir/src"
fi
done <<< "$dirs"
}
export jump() {
local last_jump_file="/tmp/last_jump.dat"
local cwd=$(pwd)
if [[ $1 == '-' ]]; then
new_path=$(cat "$last_jump_file")
if [[ -z "$new_path" ]]; then
echo "Last jump not defined"
return
fi
cd $new_path
else
git_root=$(git rev-parse --show-toplevel)
cd "$git_root/../$1/${cwd/$git_root/}"
fi
echo "$cwd" > "$last_jump_file"
}
get_share_url() {
local response=$(curl --header "X-Api-Key: projectx_webapp" "https://invitations-stage.adobe.io/api/v4/auth/urn:aaid:sc:VA6C2:f5dbce61-a6bd-4a9e-9f29-921a256b0983?cdnAcceleration=true")
local url=$(jq '.accessURL' <<< $response | sed 's/\"//g')
local accessToken=$(jq '.accessToken' <<< $response | sed 's/\"//g')
echo "$url?access_token=$accessToken&api_key=projectx_webapp"
open "$url?access_token=$accessToken&api_key=projectx_webapp"
}