-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.zsh_functions
57 lines (53 loc) · 1.4 KB
/
.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
# ~/.zsh_functions - File for user-defined functions
# cdp: Change directory to a specific project
# Usage: cdp <project_name>
cdp() {
if [ -z "$1" ]; then
echo "Usage: cdp <project_name>" >&2
return 1
fi
if [ ! -d "$HOME/projects" ]; then
echo "Projects directory not found: $HOME/projects" >&2
return 1
fi
cd "$HOME/projects/$1" || {
echo "Project not found: $1" >&2
return 1
}
}
# docker-cleanup: Remove unused Docker objects
# Cleans up containers, images, volumes, and networks to free space
docker-cleanup() {
docker container prune -f
docker image prune -f
docker volume prune -f
docker network prune -f
}
# kctx: Switch Kubernetes context
# Usage: kctx <context_name>
kctx() {
if [ -z "$1" ]; then
echo "Available contexts:"
kubectl config get-contexts || {
echo "Failed to list contexts" >&2
return 1
}
return 0
fi
kubectl config use-context "$1" || {
echo "Failed to switch context to $1" >&2
return 1
}
}
# gclone: Clone a Git repository and navigate into its directory
# Usage: gclone <repository_url>
gclone() {
if [ -z "$1" ]; then
echo "Usage: gclone <repository_url>" >&2
return 1
fi
git clone "$1" && cd "$(basename "$1" .git)" || {
echo "Failed to clone repository: $1" >&2
return 1
}
}