-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy path.functions
134 lines (112 loc) · 3.16 KB
/
.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
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# Makes a new directory and cds to it
mcd () {
mkdir -p $1 && cd $1
}
# For handling common typos that I make all the time
function cim() {
vim $1
}
function bim() {
vim $1
}
function ci() {
vi $1
}
function bi () {
vi $1
}
# For handling common nvim typos
function nvmi() {
nvim $1
}
function nbim() {
nvim $1
}
function ncim() {
nvim $1
}
# Extract most know archives with one command
function extract()
{
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xvf $1 ;;
*.tbz2) tar xvjf $1 ;;
*.tgz) tar xvzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via >extract<" ;;
esac
else
echo "'$1' is not a valid file!"
fi
}
# Creates an archive (*.tar.gz) from given directory.
function maketar() { tar cvzf "${1%%/}.tar.gz" "${1%%/}/"; }
# Create a ZIP archive of a file or folder.
function zipf() { zip -r "${1%%/}.zip" "$1" ; }
# TerraGrunt Clear cache
function tgc() {
echo "Are you sure you want to delete .terragrunt-cache directory and .terraform.lock.hcl file? (y/n)"
read answer
if [ "$answer" != "${answer#[Yy]}" ] ;then
find . -iname ".terragrunt-cache" -type d -exec rm -rf {} +;
find . -iname ".terraform.lock.hcl" -type f -exec rm -rf {} +;
else
echo "Exiting..."
exit 1
fi
}
function nmc() {
echo "Are you sure you want to delete node_modules recursively? (y/n)"
read answer
if [ "$answer" != "${answer#[Yy]}" ] ;then
find . -iname "node_modules" -type d -exec rm -rf {} +;
else
echo "Exiting..."
exit 1
fi
}
function move_env_file() {
if [ -f .env.local ]; then
echo "A .env.local file already exists. Do you want to overwrite it? (y/n)"
read answer
if [ "$answer" = "y" ]; then
cp .env.local .env.local-$(date +%Y%m%d-%H%M%S)
cp $1 .env.local
fi
else
cp $1 .env.local
fi
}
# a function to kill all processes on a given port
function killport() {
lsof -t -i tcp:$1 | xargs kill
}
# Function to create a pull request with the base branch set to the current main branch of the repository
function create_pr() {
# Get the current main branch of the repository
current_main_branch=$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
# Execute the gh pr create command with the base set to the current main branch
gh pr create --base "$current_main_branch"
}
# Function to view the current pull request
function view_pr() {
gh pr view --web
}
# Functions needed for the copilot aliases to work
eval_git_question() {
eval "gh copilot suggest -t git \"$1\""
}
eval_gh_question() {
eval "gh copilot suggest -t gh \"$1\""
}
eval_shell_question() {
eval "gh copilot suggest -t shell \"$1\""
}