- Assumes it is run from the project root
- Creates the directory and all intermediate directories that don't yet exist
- Places an empty file, .keep, in the new directory
- Adds the directory to .gitignore and excludes the .keep file in the .gitignore
- The file type just gets syntax highlighting right - copy the function and add it to you .zshrc or .bash_profile or whatever
Last active
May 14, 2019 15:00
-
-
Save jswright61/1b9790f8306f775d412fa6d372da3391 to your computer and use it in GitHub Desktop.
Bash / Zsh function to create .keep files
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
function keep() { | |
if [ $# -eq 0 ]; then | |
echo "Please provide a directory name" | |
else | |
mkdir -p "$1" | |
touch "$1/.keep" | |
echo "$1/*" >> .gitignore | |
echo "!$1/.keep" >> .gitignore | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment