Rohit
Rohit

Reputation: 6020

Open new file from terminal with textmate

I have Textmate's terminal tools "mate" installed on my computer. I can open existing files from the terminal but cannot create new files. Here's what I get:

> mate mynewfile.txt & 

The file /Users/aging_gorilla/mynewfile.txt does not exist.

So how do I open a new file with mate?

Thanks

I am using Textmate v1.5.11

Upvotes: 1

Views: 1397

Answers (1)

Will
Will

Reputation: 4713

To create a file if it doesn't exist you can use the touch command line tool.

You can modify your command to be:

$ touch mynewfile.txt && mate mynewfile.txt

If you are using bash or something you can save this as a function to make your life easier. Add something like this to your ~/.profile script:

function mymate {
    touch $1 && mate $1
}

If you want to be able to use it with multiple files like the mate command line tool try this:

function mymate {
    for f in $*
    do
        touch $f
    done
    mate $*
}

You can then use these from the command line like so:

$ mynate file.txt

Upvotes: 1

Related Questions