One of the first scripts in the book is a script to edit scripts. But that elicits a bootstrapping problem. Without the edit script, you can’t use the edit script to edit the edit script!
This edit script ensures that the script you’re editing or creating exists and that it is recognized as a script file by the operating system. For more information about the script, read 42 Astoundingly Useful Scripts and Automations for the Macintosh•. Basically, however, here is how to create the script:
- Open the Terminal app (in your Utilities folder, which is in your Applications folder).
-
Type the following (not including any list markers), pressing return at the end of each line:
- mkdir -p ~/bin
- touch ~/bin/edit
- chmod u+x ~/bin/edit
- open -t ~/bin/edit
- At this point, you should be in TextEdit. Paste in the code below and save.
At that point, you should be able to type edit SCRIPTNAME in Terminal, and automatically do all of the above steps for future scripts.
- #!/bin/zsh
- #edit a script file
- mkdir -p $HOME/bin
- FILE=$HOME/bin/$1
- touch "$FILE"
- chmod u+x "$FILE"
- open -t "$FILE"
I’ll have more about copying and pasting from ebooks in a future post. Or, of course, you can type into TextEdit far more easily than typing on a 64 by 16 screen as we used to have to do with books like this.
- 42 Astoundingly Useful Scripts and Automations for the Macintosh•: Jerry Stratton at Amazon.com (paperback)
- If you have a Macintosh and you want to get your retro on, take a look at 42 Astoundingly Useful Scripts and Automations for the Macintosh. These modern scripts will help you work faster and more reliably, and inspire your own custom scripts for your own workflow.
More text editors
- Renumber selected lines of text
- This very short script renumbers lines of text and normalizes on a single tab/space combination in front of each number.
- Must-have iOS app: Editorial
- Editorial stands out among Markdown editors by being far more flexible and at the same time easier to use.