feat: restructure repo
This commit is contained in:
65
configs/zsh/functions/co.zsh
Normal file
65
configs/zsh/functions/co.zsh
Normal file
@ -0,0 +1,65 @@
|
||||
# Helps navigating COCO directory
|
||||
function co(){
|
||||
|
||||
cd ~/COCO
|
||||
|
||||
openCode=false
|
||||
|
||||
if [ "$1" = "o" ]; then
|
||||
1=$2;
|
||||
openCode=true
|
||||
fi
|
||||
|
||||
first_dir=${1%/*};
|
||||
second_dir=${1#*/};
|
||||
|
||||
if [ -z $first_dir ]; then
|
||||
first_dir=""
|
||||
fi
|
||||
|
||||
if [ -z $second_dir ]; then
|
||||
second_dir=""
|
||||
fi
|
||||
|
||||
if [ ! -v $first_dir ]; then
|
||||
coco_dir=$(ls | grep $first_dir | head -n 1)
|
||||
|
||||
if [ -z "$coco_dir" ]; then
|
||||
|
||||
echo "No directory exists for course $first_dir. Create a new one? (y/n)"
|
||||
|
||||
read createDir
|
||||
|
||||
if [ "$createDir" = "y" ]; then
|
||||
echo "What should the name be?"
|
||||
read dirName
|
||||
dirName=$first_dir"_$dirName"
|
||||
mkdir $dirName
|
||||
cd $dirName
|
||||
echo "Created $dirName"
|
||||
fi
|
||||
|
||||
|
||||
else
|
||||
|
||||
cd $coco_dir
|
||||
amount=$(find ./* -maxdepth 0 -type d | wc -l)
|
||||
|
||||
if [ "$amount" = "1" ]; then
|
||||
dir=$(find ./* -maxdepth 0 -type d)
|
||||
cd $dir
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
if [ $second_dir != $first_dir ]; then
|
||||
cd $second_dir
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
if [ $openCode = true ]; then
|
||||
code-insiders .
|
||||
fi
|
||||
|
||||
}
|
12
configs/zsh/functions/fx.zsh
Normal file
12
configs/zsh/functions/fx.zsh
Normal file
@ -0,0 +1,12 @@
|
||||
# Helps navigating Sync directory
|
||||
function fx(){
|
||||
cd $HOME/SYNC/
|
||||
|
||||
if [ "$2" != "" ]; then
|
||||
cd $2
|
||||
fi
|
||||
|
||||
if [ "$1" = "o" ]; then
|
||||
code-insiders .
|
||||
fi
|
||||
}
|
68
configs/zsh/functions/start.zsh
Normal file
68
configs/zsh/functions/start.zsh
Normal file
@ -0,0 +1,68 @@
|
||||
# Helps with starting stuff
|
||||
function start(){
|
||||
|
||||
serviceName=$1;
|
||||
|
||||
if [ $serviceName = "docker" ]; then
|
||||
|
||||
dockerStatus="$(service docker status)"
|
||||
|
||||
if [ "${dockerStatus#*"not running"}" != "$dockerStatus" ]; then
|
||||
echo "➜ starting docker"
|
||||
echo "➜ $(sudo service docker start)"
|
||||
fi
|
||||
|
||||
sleep 0.5
|
||||
|
||||
elif [ $serviceName = "mongo" ]; then
|
||||
|
||||
start docker
|
||||
|
||||
start container mongo
|
||||
|
||||
elif [ $serviceName = "dc" ]; then
|
||||
|
||||
start docker
|
||||
|
||||
echo "➜ starting docker-compose"
|
||||
|
||||
dc up -d
|
||||
|
||||
elif [ $serviceName = "spring" ]; then
|
||||
|
||||
start mongo
|
||||
|
||||
echo "➜ starting spring-boot"
|
||||
|
||||
mvn spring-boot:run
|
||||
|
||||
elif [ $serviceName = "container" ]; then
|
||||
|
||||
containerName=$2;
|
||||
|
||||
containerInfo="[port:$(docker port $containerName) volume:$(docker inspect -f '{{index (.HostConfig.Binds) 0}}' $containerName)]"
|
||||
|
||||
containerIsRunning="$(docker inspect -f '{{.State.Running}}' $containerName 2>/dev/null)"
|
||||
|
||||
containerStatus="$(docker inspect -f '{{.State.Status}}' $containerName 2>/dev/null)"
|
||||
|
||||
if [ $containerIsRunning = "true" ]; then
|
||||
echo "➜ $containerName already running $containerInfo"
|
||||
elif [ $containerStatus = "exited" ]; then
|
||||
echo "➜ running $containerName $containerInfo"
|
||||
echo "➜ id:$(sudo docker start $containerName)"
|
||||
else
|
||||
echo "➜ container $containerName $containerInfo doesnt exist"
|
||||
fi
|
||||
|
||||
elif [ $serviceName = "dc" ]; then
|
||||
|
||||
start docker
|
||||
|
||||
echo "➜ starting docker-compose"
|
||||
|
||||
dc up -d
|
||||
|
||||
fi
|
||||
|
||||
}
|
22
configs/zsh/functions/wp.zsh
Normal file
22
configs/zsh/functions/wp.zsh
Normal file
@ -0,0 +1,22 @@
|
||||
# Helps navigating wordpress directory
|
||||
function wp(){
|
||||
|
||||
first_dir=${1%/*}
|
||||
second_dir=${1#*/}
|
||||
|
||||
if [ $first_dir = $second_dir ]; then
|
||||
second_dir=""
|
||||
fi
|
||||
|
||||
if [ $first_dir = "plugins" ]; then
|
||||
cd "wp-content/plugins"
|
||||
elif [ $first_dir = "themes" ]; then
|
||||
cd "wp-content/themes"
|
||||
fi
|
||||
|
||||
if [ $second_dir != "" ]; then
|
||||
|
||||
fi
|
||||
|
||||
|
||||
}
|
17
configs/zsh/functions/y.zsh
Normal file
17
configs/zsh/functions/y.zsh
Normal file
@ -0,0 +1,17 @@
|
||||
function y(){
|
||||
word=$(echo "$1" | fold -w 1)
|
||||
for char in $(echo $word)
|
||||
do
|
||||
if [ $char = "i" ]; then
|
||||
yarn install
|
||||
elif [ $char = "d" ]; then
|
||||
yarn dev
|
||||
elif [ $char = "b" ]; then
|
||||
yarn build
|
||||
elif [ $char = "a" ]; then
|
||||
yarn add
|
||||
elif [ $char = "u" ]; then
|
||||
yarn upgrade
|
||||
fi
|
||||
done
|
||||
}
|
Reference in New Issue
Block a user