Mac OS下新建文本文档
---恢复内容开始---
### 介绍
不知道小伙伴们有没有发现这样一件事情: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下新建文本文档的更多相关文章
- Windows右击无新建文本文档怎么办
右击无新建文本文档2008-07-26 16:51 刚在网上找的,在运行项输入notepad,把下面的复制进去,然后保存为123.reg,双击导入. REGEDIT4 [HKEY_CLASSES_RO ...
- Win7如何自定义鼠标右键菜单 添加新建文本文档
鼠标右键新建文本文档.reg REGEDIT4 [HKEY_CLASSES_ROOT\.txt] @="txtfile" "Content Type"=&quo ...
- 电脑右键新建文本文档(txt)消失的解决办法
其实只需要一个注册表就可以了 下载地址http://pan.baidu.com/s/1hr7r0fM 拿走不谢! 注册表的内容是这样的,你也可以新建一个文件把后缀名改成.reg然后把下面的内容copy ...
- java代码---------实现File的目录下创建文本文档
总结:虽然他没教给我们很多,但是他已经很棒了 package com.a.b; import java.io.*; public class dd { public static void main( ...
- 桌面右键没有新建txt文本文档的快捷方式、
先新建一个word文档,然后将后缀名改为 TXT. 在里面输入:Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\.txt] @=&quo ...
- Java 把一个文本文档的内容复制到另一个文本文档
src.txt放在工程目录下,dest.txt可创建,也可不创建.一旦运行程序,如果dest.txt不存在,将自行创建这个文本文档,再将src.txt中的内容复制到dest.txt import ja ...
- mac os 下搭建android开发环境
mac os 下搭建android开发环境 周银辉 mac os 下搭建android环境比较方便, 如下几个步骤: 1,安装jdk 先搞清楚自己是否已经安装,在命令行下:java -version, ...
- c#读取文本文档实践3-写入到文本本文档
首先通过File.ReadAllLines()方法读入文本文档中内容并返回字符串数组contents,这样每行数据就成为了这个字符串数组contents的一个元素,再利用split()方法将每一个元素 ...
- c#读取文本文档实践1-File.ReadAllLines()
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.I ...
随机推荐
- centos安装postgresql
#安装postgresqlyum -y install postgresql-server #执行数据库初始化脚本service postgresql-9.2 initdb #启动服务service ...
- UIViewController新方法的使用(transitionFromViewController:toViewController:duration:options:animations:completion:)
iOS5中,UIViewController新添加了几个方法: - (void)addChildViewController:(UIViewController *)childController N ...
- C#常见的概念阐述
在上篇文章中,你跟着我写了一个HelloWorld,本篇中,我们来谈谈一些C#程序中的小概念 1.C# 程序结构 一个 C# 程序主要包括以下部分: 命名空间声明(Namespace declarat ...
- GB28181出内网
最近关注GB28181的朋友很多,昨天有位朋友问到GB28181出内网的问题,希望我花5分钟的时间 讲讲如何通过GB28181协议将内网的摄像机视频推送到公网.要说清楚这个问题,5分钟的时间应该不 够 ...
- 12个高效的VS调试技巧
介绍 调试是软件开发周期中的一个很重要的部分,有时很有挑战性,有时候则让程序员迷惑,有时候让程序员发疯,但是.可以肯定的是,对于任何不是太那个微不足道的程序来说,调试是不可避免的.近年来,调试工具的发 ...
- 标准库 - 输入输出处理(input and output facilities) lua
标准库 - 输入输出处理(input and output facilities)责任编辑:cynthia作者:来自ITPUB论坛 2008-02-18 文本Tag: Lua [IT168 技术文档] ...
- Swing实现系统托盘
/* 实现系统托盘化 */ protected void setToolSystemTray() { // 系统是否支持系统托盘 if (SystemTray.isSupported()) { // ...
- NIM游戏策略
NIM取子游戏是由两个人面对若干堆硬币(或石子,或..)进行的游戏,游戏由两个人进行,设有k>=1堆硬币,各堆含有n1,n2,n3,n4.....,nk个硬币,游戏的目的就是选取最后剩下的硬币. ...
- Dispose模式释放非托管资源
实现方式用的是设计模式里的模板模式,基类先搭好框架,子类重写void Dispose(bool disposing) 即可. 需要注意的是基类的Finalize函数也就是析构函数调用的是虚函数void ...
- 最小生成树——Kruskal(克鲁斯卡尔)算法
[0]README 0.1) 本文总结于 数据结构与算法分析, 源代码均为原创, 旨在 理解 Kruskal(克鲁斯卡尔)算法 的idea 并用 源代码加以实现: 0.2)最小生成树的基础知识,参见 ...