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

    ----不要温顺地走进那良宵
  • 相关阅读:
    spring学习之@SessionAttributes
    Spring MVC @SessionAttributes注解
    SpringBoot yml 配置 多配置文件,开发环境,生产环境配置文件分开
    java 常用集合list与Set、Map区别及适用场景总结
    JAVA中String.format的用法 格式化字符串,格式化数字,日期时间格式化,
    Spring注解详解@Repository、@Component、@Service 和 @Constroller
    使用idea 在springboot添加本地jar包的方法本地运行有效,一旦需要打jar就会报错,这就需要在
    使用idea 在springboot添加本地jar包的方法 部署的时候本地jar没有包含的解决方法
    IDEA 快速将spring boot项目打包成jar包,简单快速有效
    java 泛型详解-绝对是对泛型方法讲解最详细的,没有之一
  • 原文地址:https://www.cnblogs.com/Hist/p/5018146.html
Copyright © 2011-2022 走看看