zoukankan      html  css  js  c++  java
  • 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 -> 服务 -> 新建文档来在当前位置新建一个无格式文档了。当然,你也可以自己设置快捷键让新建文档更加方便。

    ----不要温顺地走进那良宵
  • 相关阅读:
    Dash panel 里面添加启动项
    Ubuntu安装chrome
    多核CPU服务器 tomcat配置
    Iptux 信使 自动缩小问题 ubuntu12.04
    Html5 上传文件
    ubuntu 12.04 字体设置
    Ubuntu12.04 Eclipse 背景颜色 修改
    一些需要禁用的PHP危险函数
    Oracle 修改带数据的字段类型
    oracle 中同一个字段1 ,字段追加,字段部分数据删除
  • 原文地址:https://www.cnblogs.com/Hist/p/5018146.html
Copyright © 2011-2022 走看看