惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

C
CXSECURITY Database RSS Feed - CXSecurity.com
GbyAI
GbyAI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Y
Y Combinator Blog
U
Unit 42
M
MIT News - Artificial intelligence
F
Fortinet All Blogs
MongoDB | Blog
MongoDB | Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Hugging Face - Blog
Hugging Face - Blog
B
Blog
T
Tailwind CSS Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
H
Help Net Security
D
Docker
NISL@THU
NISL@THU
P
Privacy International News Feed
L
Lohrmann on Cybersecurity
Scott Helme
Scott Helme
P
Palo Alto Networks Blog
S
Securelist
WordPress大学
WordPress大学
B
Blog RSS Feed
Blog — PlanetScale
Blog — PlanetScale
有赞技术团队
有赞技术团队
L
LINUX DO - 热门话题
人人都是产品经理
人人都是产品经理
博客园 - 聂微东
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Security Latest
Security Latest
D
DataBreaches.Net
T
The Exploit Database - CXSecurity.com
Recorded Future
Recorded Future
Stack Overflow Blog
Stack Overflow Blog
T
The Blog of Author Tim Ferriss
The Hacker News
The Hacker News
I
Intezer
T
Threat Research - Cisco Blogs
Cyberwarzone
Cyberwarzone
C
Cyber Attacks, Cyber Crime and Cyber Security
P
Privacy & Cybersecurity Law Blog
Cisco Talos Blog
Cisco Talos Blog
L
LangChain Blog
Jina AI
Jina AI
量子位
V
V2EX
阮一峰的网络日志
阮一峰的网络日志
Last Week in AI
Last Week in AI
AWS News Blog
AWS News Blog
Apple Machine Learning Research
Apple Machine Learning Research

herrkaefer

"Vibe planning \u003e vibe coding" "Anything to Markdown" "Built anocus: anonymous commenting for static sites" "日记与小说 -- AI 续写小说欣赏" "Any-podcast: from newsletters to a podcast" "Made MicPipe: a simple voice input tool using ChatGPT dictation" "关于 Tools 和 Skills 的一点感想" "Realtime monitoring of ComEd hourly price" "Introducing SwiftEdgeTTS" "Thoughts on the philosophy of building AI-native apps" "jelly鼻屎" "等饭的人" "Use home assistant to motivate my kid to brush teeth" "Migrated Blog to Hugo and Cloudflare Pages" "Easy Aspen monitoring for Chicago parents" "Introducing HabitBuilder: A simple Telegram bot for habit tracking" "鼓捣" "Open folder or file with Sublime Text from Finder toolbar" "Python dev workflow on macOS" "Uno reinvented for 3-year-old kids" "Uno变身儿童数字游戏" "自动转发Twitter到微博" "Handle annoying operations of objects in Realm DB" "Move Jekyll blog to Ubuntu VPS" "Introducing Mole" "Note taking without note taking app" "Deploy Python web application on Ubuntu server" "Setup Shadowsocks / VPN on Ubuntu Server" "Linode Notes - Basic Setup" "CLASS Style Adapted for Embedded Systems" "psycopgr Tutorial" "pgRouting Notes" "PostgreSQL Notes" "阿城三王" "这一年,这一把日子" "另一面的发现——读《坟》" "定理" "封面与腰封" "Google book下载" "lulu最新写真出炉" "The Big Bang Theory第三季" "自拍婚纱照1" "日全食" "期待动画片" "《麦兜响当当》动画电影主题曲" "转:饶毅--“杂志拜物教”:何时发Cell Nature Science 论文害你" "转:饶毅--提醒年轻人:何时SCI害你?" "西安" "3d打印机" "Dropbox" "刷牙" "贴几张照片" "6156167" "永久和凤凰" "老板的想法" "春" "原来奥巴马也是个朗读者" "应邀发Freeware List 2.0" "史上最能睡的淘宝老板" "至少出名的效果是达到了" "错怪了msn" "独立游戏节2009" "114" "馒头" "Crayon Physics Deluxe" "2008,2009" "盖章记" "小虎队附身许巍" "怎么给word文档加索引:排序问题" "怎么给word文档加索引Q\u0026amp;A" "怎么给Word文档加索引" "教我如何不疯掉" "二则" "P" "哦!报告" "蓝天" "萧翰" "lm" "故宫印象" "转:美国历任总统像" "time can kill itself" "嗯" "建议,只是建议哦" "奥地利行记3" "奥地利行记2" "奥地利行记1" "叶子" "GayBoy" "天使教你扔frisbie" "门徒因何面容愁?" "手机教堂" "丝竹管弦之盛" "残奥" "争座位" "秋意浅" "总理府" "流觞曲水" "映带左右引以为" "咚咚咚 续" "茂林修竹又有"
"Create new text file from Finder toolbar"
"herrkaefer" · 2018-03-14 · via herrkaefer

Problem

Under macOS, sometimes we want to make new text files directly in place while browsing some folders in Finder. Opening a text editor, creating a file, and saving it to the target path is not efficient in this situation. However there is no built-in context menu item to do this as in Windows.

Solution

We can make an simple application from AppleScript, and place a shortcut in Finder’s toolbar. When you click the icon, a default text file will be created in current folder, and it will be in the status of renaming so that you can change the filename conveniently.

Step 1

Open Script Editor, and create a new script with the following contents:

set file_name to "untitled"
set file_ext to ".md"
set is_desktop to false

-- get folder path and if we are in desktop (no folder opened)
try
  tell application "Finder"
    set this_folder to (folder of the front Finder window) as alias
  end tell
on error
  -- no open folder windows
  set this_folder to path to desktop folder as alias
  set is_desktop to true
end try

-- get the new file name (do not override an already existing file)
tell application "System Events"
  set file_list to get the name of every disk item of this_folder
end tell

set new_file to file_name & file_ext
set x to 1

repeat
  if new_file is in file_list then
    set new_file to file_name & " " & x & file_ext
    set x to x + 1
  else
    exit repeat
  end if
end repeat

-- create and select the new file
tell application "Finder"
  activate
  set the_file to make new file at folder this_folder with properties {name:new_file}

  if is_desktop is false then
    reveal the_file
  else
    select window of desktop
    set selection to the_file
  end if

  delay 0.4
end tell

-- press enter (rename)
tell application "System Events"
  tell process "Finder"
    keystroke return
  end tell
end tell

(Acknowledgement: The script is borrowed from this post. I did a little modification by adding a delay line to avoid wrong keystroke.)

Note that you can change the default filename and suffix in the first two lines. Here I set it as Markdown file.

Step 2

Export the script as an Application, e.g. “NewTxtFileInFinder.app”, and put it in Application folder.

Step 3

In Application folder, Drag the app to the Finder’s toolbar while holding the command button.

Step 4 (optional)

Turn off the annoying warning when changing the file suffix. This can be set in Finder’s Preference -> Advanced.

Step 5 (optional)

Change app icon to a beautiful and meaningful one.

  • Find or make a icon file with suffix icns.
  • In Finder, select the app, Cmd+i to show the info panel.
  • Drag the icns file to the top-left to replace the icon.

Other solutions

An app New File Menu can add a context menu to Finder and can be used to create different documents like in Windows. It supports many formats besides text file though requires more clicks to create a new file.