Created
November 13, 2023 17:53
-
-
Save sixhat/6d710ab9f6d086eba50a4dbe15120a9c to your computer and use it in GitHub Desktop.
Create and Manage project folders with bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -euo pipefail | |
__usage="usage: new_project name <type> | |
type can be one of md, r, or any other... and accordingly it should open | |
and setup different folder structures | |
name will be the folder name where the project exists. | |
" | |
make_folder () { | |
mkdir -p "$1" | |
cd "$1" | |
} | |
project_md (){ | |
make_folder "$1" | |
local today_file="$(date +%F).md" | |
if test ! -f "$today_file"; then | |
touch "$today_file" | |
fi | |
open -a "/Applications/Visual Studio Code.app/" "$today_file" | |
} | |
project_r (){ | |
make_folder "$1" | |
local today_file="$(date +%F).r" | |
if test ! -f "$today_file"; then | |
touch "$today_file" | |
fi | |
open -a "/Applications/RStudio.app" "$today_file" | |
} | |
# Start logic bellow this line | |
if [ "$#" != 2 ]; then | |
echo "$__usage" | |
exit 1 | |
fi | |
if [ "$2" = "r" ]; then | |
project_r $1 | |
fi | |
if [ "$2" = "md" ]; then | |
project_md $1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment