mirror of
				https://github.com/Mastermindzh/dotfiles.git
				synced 2025-11-04 10:49:00 +01:00 
			
		
		
		
	chore: split aliases
This commit is contained in:
		
							
								
								
									
										16
									
								
								bash/.aliases/docker.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								bash/.aliases/docker.sh
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,16 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
# useful docker commands
 | 
			
		||||
alias stop-dockers='docker stop $(docker ps -aq)'
 | 
			
		||||
alias docker-clean-containers='docker container prune -f --filter "until=48h"'
 | 
			
		||||
alias docker-clean-images='docker image prune -a -f --filter "until=48h"'
 | 
			
		||||
alias docker-clean-volumes='docker volume prune -f --filter "label!=keep"'
 | 
			
		||||
alias docker-clean-networks='docker network prune -f --filter "until=24h"'
 | 
			
		||||
alias docker-clean-all='stop-dockers && docker-clean-containers && docker-clean-images && docker-clean-volumes && docker-clean-networks'
 | 
			
		||||
 | 
			
		||||
# useful dockers
 | 
			
		||||
alias phpserver='docker run --rm -p 2000:80 -v "$PWD":/var/www/html mastermindzh/php-xdebug'
 | 
			
		||||
alias nodeserver='docker run --rm -p 3000:3000 -v "$PWD":/app mastermindzh/generic_node'
 | 
			
		||||
alias reactserver='docker run --rm -p 8080:8080 -v "$PWD":/app mastermindzh/generic_node'
 | 
			
		||||
alias mongoserver='docker run -d --rm -p 27017:27017 --name mongo-server -e MONGO_INITDB_ROOT_USERNAME=admin -e MONGO_INITDB_ROOT_PASSWORD=123 -v ~/.db/mongo:/data/db mongo'
 | 
			
		||||
alias sqlserver='docker run --rm --name sql-server -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=Your_Password123" -p 1433:1433 -v ~/.db/mssql:/var/opt/mssql mcr.microsoft.com/mssql/server'
 | 
			
		||||
alias mailcatcher='docker run -d -p 1080:1080 -p 1025:1025 --name mailcatcher schickling/mailcatcher'
 | 
			
		||||
							
								
								
									
										50
									
								
								bash/.aliases/kubernetes.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								bash/.aliases/kubernetes.sh
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,50 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
# Kubernetes commands
 | 
			
		||||
alias mkubectl='microk8s.kubectl'
 | 
			
		||||
alias kubestart='microk8s.start'
 | 
			
		||||
alias kubestop='microk8s.stop'
 | 
			
		||||
alias kubecontexts='kubectl config get-contexts'
 | 
			
		||||
 | 
			
		||||
# function to switch kubernetes namespace
 | 
			
		||||
kubenamespaceswitch() {
 | 
			
		||||
  if [ -z "$1" ]; then
 | 
			
		||||
    echo "please specify a namespace to switch to"
 | 
			
		||||
  else
 | 
			
		||||
    kubectl config set-context --current --namespace="$1"
 | 
			
		||||
  fi
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# function to switch kubernetes context
 | 
			
		||||
kubecontextswitch() {
 | 
			
		||||
  if [ -z "$1" ]; then
 | 
			
		||||
    echo "please specify a context to switch to, the following contexts are available:"
 | 
			
		||||
    kubectl config get-contexts
 | 
			
		||||
  else
 | 
			
		||||
    kubectl config use-context "$1"
 | 
			
		||||
  fi
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# function to switch to a different azure kubernetes cluster
 | 
			
		||||
azkubeswitch() {
 | 
			
		||||
  if [ -z "$2" ]; then
 | 
			
		||||
    echo "please execute with the following params: azkubeswitch {resourcegroupname} {clustername}"
 | 
			
		||||
  else
 | 
			
		||||
    az aks get-credentials --resource-group "$1" --name "$2"
 | 
			
		||||
  fi
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# get old resources from kubernetes
 | 
			
		||||
kube-get-old() {
 | 
			
		||||
  if [ -z "$1" ]; then
 | 
			
		||||
    echo "please provide a resource type, examples:"
 | 
			
		||||
    echo "  kube-get-old pods"
 | 
			
		||||
    echo "  kube-get-old namespaces"
 | 
			
		||||
    echo ""
 | 
			
		||||
    echo "you can pass extra arguments as the second param, examples:"
 | 
			
		||||
    echo "  kube-get-old pods --all-namespaces"
 | 
			
		||||
    echo '  kube-get-old namespaces "--all-namespaces --second"'
 | 
			
		||||
  else
 | 
			
		||||
 | 
			
		||||
    kubectl get "$1" ${2:+"$2"} -o go-template --template '{{range .items}}{{.metadata.name}} {{.metadata.creationTimestamp}}{{"\n"}}{{end}}' | awk -v twoWeeksAgo="date -d '-14 days'" -F':' '$2<twoWeeksAgo' | awk '{print $1}'
 | 
			
		||||
  fi
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										4
									
								
								bash/.aliases/node.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								bash/.aliases/node.sh
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,4 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
alias clean-node-modules='find . -name "node_modules" -type d -print0 |xargs -0 rm -r --'
 | 
			
		||||
alias organize-package-json='npx format-package -w && npx sort-package-json'
 | 
			
		||||
		Reference in New Issue
	
	Block a user