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

    ----不要温顺地走进那良宵
  • 相关阅读:
    微信·小程序开发工具安装指南及注意事项
    测试
    PC上面的蓝牙的通信(C#)
    关于图片在div中居中问题
    JSONP---跨域请求问题
    关于position的用法
    APICloud自学笔记总结1
    前端html5
    关于图片自适应div大小问题
    亲身经历——大体量公司能为程序员的生涯带来什么帮助?
  • 原文地址:https://www.cnblogs.com/Hist/p/5018146.html
Copyright © 2011-2022 走看看