# Opening Sublime Text from the command line

DevFeed: [Opening Sublime Text from the command line](<https://devfeed.tech/articles/opening-sublime-text-from-the-command-line-39471.md>)

Original publisher: [Read original article](<https://akrabat.com/opening-sublime-text-from-the-command-line/>)

Author: Rob

Published: 2026-06-30T10:00:00Z

Content type: tutorial

Language: en

Sources: [Rob Allen](<https://devfeed.tech/sources/rob-allen.md>)

Topics: [Sublime Text](<https://devfeed.tech/topics/sublime-text.md>), [Command-line interface](<https://devfeed.tech/topics/cli.md>), [Bash](<https://devfeed.tech/topics/bash.md>), [JSON](<https://devfeed.tech/topics/json.md>), [sessions](<https://devfeed.tech/topics/sessions.md>)

Tags: [bash](<https://devfeed.tech/tags/bash.md>), [command-line](<https://devfeed.tech/tags/command-line.md>), [computing](<https://devfeed.tech/tags/computing.md>), [extension](<https://devfeed.tech/tags/extension.md>), [json](<https://devfeed.tech/tags/json.md>), [sessions](<https://devfeed.tech/tags/sessions.md>), [shell-scripting](<https://devfeed.tech/tags/shell-scripting.md>), [software](<https://devfeed.tech/tags/software.md>)

## AI overview

A tutorial on using a Bash function to open Sublime Text from the command line with different window behaviors for directories and files. It extends the function to create and manage a hidden .sublime-project JSON file so open files persist across sessions.

## Source excerpt

I nearly always open Sublime Text from the command line using subl and have specific requirements for when it should open a new window or re-use one. If I'm opening a directory, then I would like it to re-use the same window if I have previously opened that directory. However if I open a random file, I never want that file in the last directory window as it's unrelated. To do this I wrote a... continue reading.