Skip to content

Instantly share code, notes, and snippets.

@jaredyam
Last active November 14, 2020 10:21
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 jaredyam/c4639a8094bb2183135a5703fd056c48 to your computer and use it in GitHub Desktop.
Save jaredyam/c4639a8094bb2183135a5703fd056c48 to your computer and use it in GitHub Desktop.
Fix the issue that [project-name].sublime-project setting file not works when open sublime project with the terminal command [subl project-directory]
# Wrap up the [subl] command with the ability that auto-activate the .sublime-project setting file under project directory.
#
# relative issue / solution
# -------------------------
# 1. https://stackoverflow.com/questions/14203944/sublime-text-folder-exclude-patterns-stopped-working
# 2. https://forum.sublimetext.com/t/project-settings-when-opened-with-subl/11419
# 3. https://gist.github.com/imjared/7010577
function subl() {
sublime_project_file="${1##*/}.sublime-project"
if [ "$1" = "." ] && [ -f "${PWD##*/}.sublime-project" ]; then
command subl "${PWD##*/}.sublime-project"
elif [ "$1" = ".." ] && [ -f "../$(pwd | awk -F'/' '{print $(NF-1)}').sublime-project" ]; then
command subl "../$(pwd | awk -F'/' '{print $(NF-1)}').sublime-project"
elif [ -f "$1/$sublime_project_file" ]; then
command subl "$1/$sublime_project_file"
else
command subl "$1"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment