feat: restructure repo

This commit is contained in:
2020-11-08 21:55:05 +01:00
parent 6d45d2f0cd
commit ad4ca67841
23 changed files with 441 additions and 261 deletions

25
configs/zsh/aliases.sh Normal file
View File

@ -0,0 +1,25 @@
## ALIASIES ##
alias -s {yml,yaml,ts,json,js,vim,rc}=nvim
alias ci="code-insiders"
alias yoink="curl"
alias pls='sudo -E env "PATH=$PATH"'
alias zshc="vim ~/.zshrc"
alias zshu="source ~/.zshrc"
alias nano="nvim"
alias ww="webpack -w"
alias gs="git status"
alias gaa="git add ."
alias gpm="git push origin main"
alias gcm="git commit -m "
alias czi="commitizen init cz-conventional-changelog --yarn --dev --exact"
alias cz="git-cz"
alias lt="tree -L 2 --filelimit 150 --dirsfirst"
alias dc="docker-compose"

View File

@ -0,0 +1,5 @@
source $(dirname "$0")/functions/co.zsh;
source $(dirname "$0")/functions/fx.zsh;
source $(dirname "$0")/functions/start.zsh;
source $(dirname "$0")/functions/wp.zsh;
source $(dirname "$0")/functions/y.zsh;

View 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
}

View 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
}

View 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
}

View 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
}

View 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
}