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 ...
随机推荐
- HTTP协议断点续传
using System;using System.Collections.Generic;using System.IO;using System.Linq;using System.Net;usi ...
- sql2000实现row_number
一.以PersonID,classid,dt_ClassData为条件进行分组,每个小组加序号,row_number在sql2005中不可用 方法一.sql2000及以上版本--以PersonID,c ...
- DOM概念的区分:Attribute和Property, html()及.text(), .val()
Attribute就是dom节点自带的属性 例如:html中常用的id.class.title.align等: <div id="immooc" title="慕课 ...
- CentOS上yum安装Nginx服务
一.更改yum源为网易的源加快速度 vi /etc/yum.repos.d/CentOS-Base.repo更改内容如下 # CentOS-Base.repo # # This file uses a ...
- 浅谈BloomFilter【上】基本概念和实现原理
在日常生活中.包括在设计计算机软件时,我们常常要推断一个元素是否在一个集合中. 比方在字处理软件中,须要检查一个英语单词是否拼写正确(也就是要推断 它是否在已知的字典中).在 FBI. ...
- Arcgis:什么是栅格数据类型
栅格数据单元大小 栅格所表示的内容的详细程度(要素现象)通常取决于栅格的单元(像素)大小或空间分辨率. 单元必须足够小,这样才可以捕获到所需的详细信息: 而单元又必须足够大,这样才可以提高计算机存储和 ...
- oracle中过滤中文字符或者汉字的函数
CREATE OR REPLACE FUNCTION GET_CHINESE(P_NAME IN VARCHAR2) RETURN VARCHAR2 IS V_CODE VARCHAR2 ...
- MongoDB入门学习(1)
什么是MongoDB ? MongoDB 是由C++语言编写的,是一个基于分布式文件存储的开源数据库系统. 在高负载的情况下,添加更多的节点,可以保证服务器性能. MongoDB 旨在为WEB应用提供 ...
- centos6.5安装Apache+MySQL+PHP
一.安装 MySQL 首先来进行 MySQL 的安装.打开超级终端,输入: [root@localhost ~]# yum install mysql mysql-server 安装完毕,让 MySQ ...
- 【Python+selenium】之奇怪问题总结
问题1: <_io.TextIOWrapper name='<stderr>' mode='w' encoding='UTF-8'> Time Elapsed: 0:00:04 ...