在Mac中用快捷键快速插入日期时间
2019独角兽企业重金招聘Python工程师标准>>>
在Windows中有AutoHotkey这个好东东帮我快速插入日期时间,输入[mm然后敲空格就可以了。在Mac中就没有这么好的事了,虽然能够实现,但是没有AutoHotkey方便。还是要借助于AppleScript,但是并不能适用于Mac中任何文本输入的地方,比如DayOne的弹出窗口就不能用,另外还有一个限制:只能对选中的文字进行操作。
我使用的是这个文章里面的方案:
http://www.sixhat.net/applescript-insert-date-and-time-into-your-documents.html
代码是:
-- Insert Date and Time into your documents
-- @2012 David Rodrigues
set date_ to ((current date) as string)
set the clipboard to the date_
tell application "System Events"set frontmostApplication to name of the first process whose frontmost is true
end tell
tell application frontmostApplicationactivatetell application "System Events"keystroke "v" using {command down}end tell
end tell
注意它会改变粘贴板的内容。我为它定义了一个快捷键:Cmd+Alt+Shift+F。使用之前,可以先敲一个字母,然后选中字母,按这个快捷键,就会显示出来日期时间了。比如现在的时间是: 2014-12-22 19:39:03 +0800。
下面的英文描述是下面参考第一个链接文章的内容,有时间再翻译。
Below is a very simple AppleScript that inserts the date, time and timezone in the format that Jekyll requires.
do shell script "date +%Y-%m-%d\\ %H:%M:%S\\ %z"
To make inserting it simple, it’s possible to assign a keyboard shortcut, by turning it into a Service in Automator.
Open Automator.app
Create a new Service
Set it to receive selected text in any application
Check the ‘Output replaces selected text’ tick-box
Insert the ‘Run AppleScript’ action
Copy and paste the above AppleScript
Press run to make sure it works
Save the
.workflow
file to~/Library/Services
Open the
Keyboard > Keyboard Shortcuts
system preference pane, select Services in the left column, then find the Service you just created.Assign a keyboard shortcut. I use
Command
+Option
+d
There is one pitfall: it only works on selected text.
When saving a post for Jekyll, the file-name also requires a date—but not a time. For this, you can follow the same process as above with a modified AppleScript:
do shell script "date +%Y-%m-%d"
For this, I use the keyboard shortcut Command
+ Option
+ Shift
+ d
.
I would love it if the Service created the entire file name. So if the post title ‘This is a Post Title’ was on the clipboard, it would create a file called 2012-11-10-this-is-a-post-title.md
; replacing spaces with hyphens and converting it to lowercase. However, that’s well beyond my very limited AppleScript knowledge.
参考:
http://andytaylor.me/2012/11/10/creating-an-osx-service-to-insert-the-current-date-and-time/
http://www.question-defense.com/2013/01/28/title-osx-keyboard-shortcut-for-insert-date-and-time-insert-datetime-in-textmate
转载于:https://my.oschina.net/ioslighter/blog/359329
在Mac中用快捷键快速插入日期时间相关推荐
- 文档中快速输入日期时间的方法
文章目录 word文档 excel表格 日期输入后固定不变 日期输入后会根据系统变化的 输入法快速输入日期时间(推荐) word文档 输入 ctrl+;,就可以直接输入当前日期 输入 ctrl+shi ...
- qt mysql 系统时间_使用QT和参数在SQLite数据库中插入日期时间
我想从C++/QT应用程序执行插入到SQLite数据库. 我想要插入数据的表格中的一列是datetime(yyyy-mm-dd hh:mm:ss).使用QT和参数在SQLite数据库中插入日期时间 我 ...
- mysql中sql插入时间_mysql中使用sql语句插入日期时间类型的写法
[例子如下: select * from ( select rownumber() over() as rownumber, id from associate ) as temp where row ...
- Word如何快速插入日期和时间
Word编辑文件时,有时需要插入日期和时间,但是一个个数字敲太麻烦,那么怎么快捷输入呢?以speedoffice为例. 首先,在"插入"菜单栏里面找到"日期.时间&quo ...
- mac numbers 计算两个日期时间天数 DUR2DAYS
mac numbers 计算两个日期之间天数的函数 DUR2DAYS =DUR2DAYS($A - $B) +1
- Rstudio 修改RMD快捷键快速插入Python代码块
Tools -> Global Options -> Code 点击 Modify Key-,在弹出的窗口搜索insert,设置完成后 Apply
- 苹果mac休眠快捷键_Mac技巧|如何高效使用苹果便笺?用便笺快捷键快速完成操作...
便笺可能是 Mac 上最没有存在感的应用之一.很多人偶尔看到或者想起来要用的时候,都会有一种 "鸡肋" 感,而且打字以外的任何操作似乎都要去到菜单栏.其实,是打开方式不太对,因为它 ...
- macos复制粘贴快捷键 快速_探究Mac OS十大键盘快捷键
无论是新手还是老手,总不能忘记mac系统给小伙伴们带来的体验感,但是总要记住10大Mac键盘快捷键方式,将减少对鼠标的依赖而帮助你更快地提高工作效率. 十大Mac键盘快捷键 首先,看一下你Mac电脑的 ...
- Mac技巧|如何高效使用苹果便笺?利用便笺快捷键快速完成操作!
便笺可能是 Mac 上最没有存在感的应用之一.很多人偶尔看到或者想起来要用的时候,都会有一种 "鸡肋" 感,而且打字以外的任何操作似乎都要去到菜单栏.其实,是打开方式不太对,因为它 ...
最新文章
- 10个最常用 Windows Vista运行命令
- [最短路]tvvj1031 热浪
- laravel进阶系列--通过事件和事件监听实现服务解耦
- php求及格,详解PHP通过递归实现提成计算
- python文件图标变成小电脑_手把手教你给Python程序写图形界面,并且打包成exe文件-exe文件...
- 值得收藏!数据分析最常用的18个概念,终于有人讲明白了
- Control的BeginInvoke和Invoke的区别
- UG编程逆向工程如何做,一起来学习
- 数学主题分类 - 中文(上)
- oracle pq distribute,详解Oracle hints PQ_DISTRIBUTE
- dede mysql x_mysql 插入数据时中文变x87xE7xA7x91xE7x82这种?
- 开源一款苹果 macOS 工具 - AppleParty(苹果派)
- 成都中忻嘉业:抖音怎样查看直播回放
- 如何制作独一无二的简历?
- 彻底理解傅里叶变换(上)
- 华为Linux如何安装微信,华为手机怎么重新安装微信?
- 步进伺服电机加减速 及 位置速度控制关键程序
- vue3安装wot-design步骤
- 任正非:华为要的是全世界
- 关于eBPF与可观测性,你想知道的都在这里
热门文章
- 在线文本并集计算工具
- 解决vue在ie9中的兼容问题
- C# 合并多种格式文件为PDF
- Facebook人工智能实验室的前世今生
- POJ 3988 Selecting courses
- Ubuntu上通过 RVM 安装 多版本 Ruby/Rails
- Symfony2Book12:HTTP 缓存
- 分布式共识算法 (Consensus Algorithm)
- c语言程序计算4阶行列式的值,如何用降阶法求解四阶行列式的计算,请帮我编一个C语言程序。...
- arduino动态刷新显示_2019 台北电脑展:华硕显示器产品精锐尽出