Last active
October 26, 2016 09:24
-
-
Save zereraz/7d5e959915aed9998a051a229dbcf143 to your computer and use it in GitHub Desktop.
a script to create c files and open it in vim, "alias c_create=. c_create" is put in .zshrc or .bashrc file
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 | |
# first argument is the name of the folder and the c file | |
fileName=$1 | |
# change to the desired folder | |
filePath='/Users/apple/Documents/coding/c/c_generated/' | |
folderToCreate="$filePath$fileName" | |
fileToCreate="$filePath$fileName/$fileName.c" | |
helloWorld="#include<stdio.h>\n\nint main(){\n\tprintf(\"Hello world\");\n}\n" | |
if [ ! -d "$folderToCreate" ]; then | |
echo "creating file at : $folderToCreate" | |
mkdir $folderToCreate && touch "$fileToCreate" | |
echo -e $helloWorld >> $fileToCreate | |
fi | |
echo "opening file : $fileName" | |
cd $folderToCreate | |
vim $fileToCreate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment