Created
November 13, 2023 17:52
-
-
Save sixhat/a5d9d95db14e02dc92c779c1ab09096a to your computer and use it in GitHub Desktop.
rc
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