Shell Script to create an empty file in the working directory (Mac OS X)

I want to write a shell script that you can remove anywhere, and when you open it, it just creates a new file in this directory. So far I have this:

#!/bin/bash
BASEDIR=$(dirname $0)
touch $BASEDIR/untitled

What works, except for two things that I would like to do so that I have no idea how to do this.

  • Is there a way to get Finder to focus on it after it is created? (for example, as Windows and most Linux distributions do when you create a new file in the right-click context menu)

  • How can I make a non open terminal script every time you click on it? Do I need to do this ".app"?

So, you get an idea of ​​where Im put it, I put it here:

enter image description here

so that I can create a new file anywhere.

+3
3

AppleScript bash. , AppleScript Finder.

AppleScript, :

do shell script "touch /foo.txt"
+2
0

I created a utility to create a file in the top finder window.

Look at this.

I also saved applescript in the article.

http://www.think-1st.com/mac-osx-create-new-file-from-finder-applescript/

0
source

All Articles