Skip to content

Instantly share code, notes, and snippets.

@reekoheek
Last active August 29, 2015 14:23
Show Gist options
  • Save reekoheek/03b33331b20c77f8884e to your computer and use it in GitHub Desktop.
Save reekoheek/03b33331b20c77f8884e to your computer and use it in GitHub Desktop.
o script
#!/bin/bash
#
# How to install:
# - Install sublime text
# - Download in ~/bin directory
# - chmod +x ~/bin/o
# - Happy coding
BASE_DIR="$1"
ABSOLUTE_PATH="$(cd "$(dirname "$BASE_DIR")"; pwd)/$(basename "$BASE_DIR")"
if [ "$1" == "" ]; then
BASE_DIR="."
ABSOLUTE_PATH="$(pwd)"
elif [ "$1" == "-h" ]; then
echo "Usage: $0 [directory-name]"
exit 1
fi
mkdir -p "$(dirname $BASE_DIR)"
PROJECT_NAME="$(basename $ABSOLUTE_PATH)"
if [ ! -f "$BASE_DIR/$PROJECT_NAME.sublime-project" ]; then
if [ -f "$BASE_DIR/project.sublime-project" ]; then
mv "$BASE_DIR/project.sublime-project" "$BASE_DIR/$PROJECT_NAME.sublime-project"
rm -rf "$BASE_DIR/project.sublime-workspace"
else
git init $BASE_DIR
cd $BASE_DIR
cat > "$PROJECT_NAME.sublime-project" <<EOL
{
"folders":
[
{
"follow_symlinks": true,
"path": ".",
"folder_exclude_patterns": [
"node_modules",
"bower_components",
"vendor"
]
}
],
"SublimeLinter":
{
"linters":
{
"phpcs":
{
"excludes":
[
"*/templates/*"
]
}
}
}
}
EOL
subl --project "$PROJECT_NAME.sublime-project"
exit
fi
fi
subl --project "$BASE_DIR/$PROJECT_NAME.sublime-project"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment