Skip to content

Instantly share code, notes, and snippets.

@dvoiss
Created February 27, 2012 00:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dvoiss/1920206 to your computer and use it in GitHub Desktop.
Save dvoiss/1920206 to your computer and use it in GitHub Desktop.
Quick bare .project file for a directory or list of directories for importation into Eclipse as stand alone "project"...
#!/bin/sh
# generates an empty .project file with just the name of the directory
# being used as the project name
# USAGE:
if [ "$1" = "-h" -o "$1" = "--help" ]; then
echo; echo "Usage: $0 [options]"
echo; echo "== Options"
echo; echo -e "Pass the string \"sub\" to generate empty .project files for \
sub-directories of this directory."
exit 0
fi
# writes the project file
write_project_file() {
project_xml="$(cat<<EOF
<projectDescription>
\n\t<name>
\n\t\t$1
\n\t</name>
\n</projectDescription>
EOF
)"
echo $project_xml > .project
}
if [ "$1" = "sub" ]; then
# go through sub-directories creating .project files for each,
# this is of little use, but it's here just 'cause :)
for i in *; do
[[ -d "$i" ]] && {
cd "$i"
write_project_file "$i"
cd ..
}
done
else
# only write .project file for current directory:
# ${PWD##*/} gets current directory name (not full path)
write_project_file "${PWD##*/}"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment