---恢复内容开始---

### 介绍

不知道小伙伴们有没有发现这样一件事情:Mac下没有新建文本文档!如果你恰好经常需要新建类似于.cpp,.in,.out等文件的话,每次终端用一堆$ cd命令再加上一句$ touch,简直是苦不堪言。好在有同样苦衷的网友早已找到了解决方案,那就是利用系统自带的Automator。

使用

1.打开实用程序 -> Automator,新建一个服务(Service).



2.从左边Library栏里找到Run Applescript选项,把它拖到右边的窗口里.

3.把右边窗口上端的Service receives选项设置为no input

4.输入以下代码:

tell application "Finder"
try
set currentFolder to (folder of the front window)
set currentPath to (POSIX path of (target of the front window as alias))
set libkIsDeskTop to false
on error
set currentFolder to desktop
set currentPath to (POSIX path of (desktop as alias))
set libkIsDeskTop to true
end try
(*
set currentPath to (POSIX path of (target of the front window as alias))
set currentFolder to (folder of the front window)
*) set baseName to "Untitled"
set txtName to baseName -- if the file name already exists in current folder, attach the "_n" to the filename
set n to 1
considering case
tell (get name of currentFolder's files) to repeat while txtName is in it
set txtName to baseName & "_" & n
set n to n + 1
end repeat
end considering set newTxt to currentPath & txtName
do shell script "touch " & newTxt
if libkIsDeskTop is false then select the file txtName in currentFolder end tell

5.按Command+s来保存,在对话框中输入“新建文档”

完成

此时,在Finder内就可以通过Finder -> 服务 -> 新建文档来在当前位置新建一个无格式文档了。当然,你也可以自己设置快捷键让新建文档更加方便。

---恢复内容结束---

### 介绍

不知道小伙伴们有没有发现这样一件事情:Mac下没有新建文本文档!如果你恰好经常需要新建类似于.cpp,.in,.out等文件的话,每次终端用一堆$ cd命令再加上一句$ touch,简直是苦不堪言。好在有同样苦衷的网友早已找到了解决方案,那就是利用系统自带的Automator。

使用

1.打开实用程序 -> Automator,新建一个服务(Service).



2.从左边Library栏里找到Run Applescript选项,把它拖到右边的窗口里.

3.把右边窗口上端的Service receives选项设置为no input

4.输入以下代码:

tell application "Finder"
try
set currentFolder to (folder of the front window)
set currentPath to (POSIX path of (target of the front window as alias))
set libkIsDeskTop to false
on error
set currentFolder to desktop
set currentPath to (POSIX path of (desktop as alias))
set libkIsDeskTop to true
end try
(*
set currentPath to (POSIX path of (target of the front window as alias))
set currentFolder to (folder of the front window)
*) set baseName to "Untitled"
set txtName to baseName (* if the file name already exists in current folder, attach the "_n" to the filename *)
set n to 1
considering case
tell (get name of currentFolder's files) to repeat while txtName is in it
set txtName to baseName & "_" & n
set n to n + 1
end repeat
end considering set newTxt to currentPath & txtName
do shell script "touch " & newTxt
if libkIsDeskTop is false then select the file txtName in currentFolder end tell

5.按Command+s来保存,在对话框中输入“新建文档”

完成

此时,在Finder内就可以通过Finder -> 服务 -> 新建文档来在当前位置新建一个无格式文档了。当然,你也可以自己设置快捷键让新建文档更加方便。

Mac OS下新建文本文档的更多相关文章

  1. Windows右击无新建文本文档怎么办

    右击无新建文本文档2008-07-26 16:51 刚在网上找的,在运行项输入notepad,把下面的复制进去,然后保存为123.reg,双击导入. REGEDIT4 [HKEY_CLASSES_RO ...

  2. Win7如何自定义鼠标右键菜单 添加新建文本文档

    鼠标右键新建文本文档.reg REGEDIT4 [HKEY_CLASSES_ROOT\.txt] @="txtfile" "Content Type"=&quo ...

  3. 电脑右键新建文本文档(txt)消失的解决办法

    其实只需要一个注册表就可以了 下载地址http://pan.baidu.com/s/1hr7r0fM 拿走不谢! 注册表的内容是这样的,你也可以新建一个文件把后缀名改成.reg然后把下面的内容copy ...

  4. java代码---------实现File的目录下创建文本文档

    总结:虽然他没教给我们很多,但是他已经很棒了 package com.a.b; import java.io.*; public class dd { public static void main( ...

  5. 桌面右键没有新建txt文本文档的快捷方式、

    先新建一个word文档,然后将后缀名改为 TXT. 在里面输入:Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\.txt] @=&quo ...

  6. Java 把一个文本文档的内容复制到另一个文本文档

    src.txt放在工程目录下,dest.txt可创建,也可不创建.一旦运行程序,如果dest.txt不存在,将自行创建这个文本文档,再将src.txt中的内容复制到dest.txt import ja ...

  7. mac os 下搭建android开发环境

    mac os 下搭建android开发环境 周银辉 mac os 下搭建android环境比较方便, 如下几个步骤: 1,安装jdk 先搞清楚自己是否已经安装,在命令行下:java -version, ...

  8. c#读取文本文档实践3-写入到文本本文档

    首先通过File.ReadAllLines()方法读入文本文档中内容并返回字符串数组contents,这样每行数据就成为了这个字符串数组contents的一个元素,再利用split()方法将每一个元素 ...

  9. c#读取文本文档实践1-File.ReadAllLines()

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.I ...

随机推荐

  1. elk systemd管理

    1.logstash /etc/systemd/system/logstash.service Type=simple User=logstash Group=logstash # Load env ...

  2. visual studio 2010 LNK1123解决方式

    ------------------------------------------------------------Lysen----------------------------------- ...

  3. Sql视图创建语句及修改视图

    create view [dbo].[AllUsers] as select u.UserId, u.Firstname, u.Lastname, u.ts, am.Email, au.UserNam ...

  4. CentOS7 yum 安装 Nginx最新版本

    CentOS7 yum 安装 Nginx最新版本 下载对应当前系统版本的nginx包(package) # wget  http://nginx.org/packages/centos/7/noarc ...

  5. SPI协议介绍

    一.概述 SPI, Serial Perripheral Interface, 串行外围设备接口, 是 Motorola 公司推出的一种同步串行接口技术. SPI 总线在物理上是通过接在外围设备微控制 ...

  6. NPOI 添加下拉列表

    需求 给指定列添加下拉列表.如下图: 思路 NPOI的文档网站不能访问了,这里参考的POI文档. 加下拉列表有两种方式,一种直接写字符串,例如 new String[]{"10", ...

  7. busybox下inittab中runlevel解析

    Order of scripts run in /etc/rc?.d ================================== 0. Overview. All scripts execu ...

  8. linux应用网址

    APUE学习:(十三) [终篇] 一起学 Unix 环境高级编程 (APUE) 之 网络 IPC:套接字 linux应用学习笔记(已列目录供跳转):http://www.cnblogs.com/ggj ...

  9. centos7 安装postgresql10

    https://blog.csdn.net/rudy5348/article/details/79299162

  10. bzoj3992【SDOI2015】序列统计

    3992: [SDOI2015]序列统计 Time Limit: 30 Sec  Memory Limit: 128 MB Submit: 673  Solved: 327 [Submit][Stat ...