ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Auto​Open​Readme

by noahcoad ST3 New

Automatically opens readme, notes, or other files when opening a folder in a new window.

Details

Installs

  • Total 0
  • Win 0
  • Mac 0
  • Linux 0
Sep 28 Sep 27 Sep 26 Sep 25 Sep 24 Sep 23 Sep 22 Sep 21 Sep 20 Sep 19 Sep 18 Sep 17 Sep 16 Sep 15 Sep 14 Sep 13 Sep 12 Sep 11 Sep 10 Sep 9 Sep 8 Sep 7 Sep 6 Sep 5 Sep 4 Sep 3 Sep 2 Sep 1 Aug 31 Aug 30 Aug 29 Aug 28 Aug 27 Aug 26 Aug 25 Aug 24 Aug 23 Aug 22 Aug 21 Aug 20 Aug 19 Aug 18 Aug 17 Aug 16 Aug 15
Windows 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Mac 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Linux 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

AutoOpenReadme

A Sublime Text package.

Open a folder, and its readme opens with it.

No commands, no key bindings, nothing to remember – it just listens for new windows.

What it opens

When you open a new window with a single folder, it looks for the first of these that exists and opens it:

readme.md → readme.txt → readme → notes.md → notes.txt

Where it looks

The folder's root first, then a docs** folder, then a **wiki folder.

Folders are searched in order and each one is checked for every filename before moving on. So a notes.txt in the root beats a readme.md in docs/:

myproject/
  docs/
    readme.md     <- 3rd choice
    notes.txt     <- 4th
  notes.txt       <- 2nd
  readme.md       <- 1st, this is what opens

Both the filenames and the folders are configurable – see below.

Config

Preferences → Package Settings → AutoOpenReadme → Settings, or from the command palette, Preferences: AutoOpenReadme Settings. Defaults:

{
    "files": ["readme.md", "readme.txt", "readme", "notes.md", "notes.txt"],
    "folders": [".", "docs", "wiki"],
    "auto_open_file": ".sublime.autoopen"
}
Setting What it does
files Filenames to look for, in priority order. First match wins.
folders Folders to look in, in order, relative to the folder you opened. "." is the root.
auto_open_file Name of the per-folder override file. See below.

Matching is whatever your filesystem does, so readme.md already finds README.md on macOS and Windows but not on a case-sensitive filesystem – add README.md to the list explicitly if you work on one. Prefer notes over readmes? Put them first:

{
    "files": ["notes.md", "notes.txt", "readme.md", "readme.txt"]
}

Per-folder override

To open something else – or several things – drop a .sublime.autoopen file in the folder listing one file per line. When that file exists, files and folders are skipped entirely and everything listed gets opened:

# .sublime.autoopen -- lines starting with # are ignored
notes.txt
docs/architecture.md
todo.md

Paths are relative to the folder holding the .sublime.autoopen. Files that don't exist are skipped quietly. Unlike the defaults, this works in multi-folder windows – every folder is checked for its own .sublime.autoopen.

Try it

mkdir ~/tmp/demo
echo "hello world" > ~/tmp/demo/readme.md
subl ~/tmp/demo

The sweet flow…

Combined with the Open URL plugin … create a projects.txt file that you put lines in for each project folder. Then just open this projects.txt file, put the cursor over a line, ctrl+u to “open url” to that folder, and bamn, the folder is opened and the appropriate readme/notes file is opened automatically.

Notes

Only fires on new windows opened with a folder, and only once per window, so it won't fight you if you close the file. Windows that already have files open are left alone.

Acknowledgments

Shout out to @josiahcoad for code reviewing and improvement ideas!

Also

Check out my other Sublime Text packages