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.

  1. Open Automator.app

  2. Create a new Service

  3. Set it to receive selected text in any application

  4. Check the ‘Output replaces selected text’ tick-box

  5. Insert the ‘Run AppleScript’ action

  6. Copy and paste the above AppleScript

  7. Press run to make sure it works

  8. Save the .workflow file to ~/Library/Services

  9. Open the Keyboard > Keyboard Shortcuts system preference pane, select Services in the left column, then find the Service you just created.

  10. 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中用快捷键快速插入日期时间相关推荐

  1. 文档中快速输入日期时间的方法

    文章目录 word文档 excel表格 日期输入后固定不变 日期输入后会根据系统变化的 输入法快速输入日期时间(推荐) word文档 输入 ctrl+;,就可以直接输入当前日期 输入 ctrl+shi ...

  2. qt mysql 系统时间_使用QT和参数在SQLite数据库中插入日期时间

    我想从C++/QT应用程序执行插入到SQLite数据库. 我想要插入数据的表格中的一列是datetime(yyyy-mm-dd hh:mm:ss).使用QT和参数在SQLite数据库中插入日期时间 我 ...

  3. mysql中sql插入时间_mysql中使用sql语句插入日期时间类型的写法

    [例子如下: select * from ( select rownumber() over() as rownumber, id from associate ) as temp where row ...

  4. Word如何快速插入日期和时间

    Word编辑文件时,有时需要插入日期和时间,但是一个个数字敲太麻烦,那么怎么快捷输入呢?以speedoffice为例. 首先,在"插入"菜单栏里面找到"日期.时间&quo ...

  5. mac numbers 计算两个日期时间天数 DUR2DAYS

    mac numbers 计算两个日期之间天数的函数 DUR2DAYS =DUR2DAYS($A - $B) +1

  6. Rstudio 修改RMD快捷键快速插入Python代码块

    Tools -> Global Options -> Code 点击 Modify Key-,在弹出的窗口搜索insert,设置完成后 Apply

  7. 苹果mac休眠快捷键_Mac技巧|如何高效使用苹果便笺?用便笺快捷键快速完成操作...

    便笺可能是 Mac 上最没有存在感的应用之一.很多人偶尔看到或者想起来要用的时候,都会有一种 "鸡肋" 感,而且打字以外的任何操作似乎都要去到菜单栏.其实,是打开方式不太对,因为它 ...

  8. macos复制粘贴快捷键 快速_探究Mac OS十大键盘快捷键

    无论是新手还是老手,总不能忘记mac系统给小伙伴们带来的体验感,但是总要记住10大Mac键盘快捷键方式,将减少对鼠标的依赖而帮助你更快地提高工作效率. 十大Mac键盘快捷键 首先,看一下你Mac电脑的 ...

  9. Mac技巧|如何高效使用苹果便笺?利用便笺快捷键快速完成操作!

    便笺可能是 Mac 上最没有存在感的应用之一.很多人偶尔看到或者想起来要用的时候,都会有一种 "鸡肋" 感,而且打字以外的任何操作似乎都要去到菜单栏.其实,是打开方式不太对,因为它 ...

最新文章

  1. 10个最常用 Windows Vista运行命令
  2. [最短路]tvvj1031 热浪
  3. laravel进阶系列--通过事件和事件监听实现服务解耦
  4. php求及格,详解PHP通过递归实现提成计算
  5. python文件图标变成小电脑_手把手教你给Python程序写图形界面,并且打包成exe文件-exe文件...
  6. 值得收藏!数据分析最常用的18个概念,终于有人讲明白了
  7. Control的BeginInvoke和Invoke的区别
  8. UG编程逆向工程如何做,一起来学习
  9. 数学主题分类 - 中文(上)
  10. oracle pq distribute,详解Oracle hints PQ_DISTRIBUTE
  11. dede mysql x_mysql 插入数据时中文变x87xE7xA7x91xE7x82这种?
  12. 开源一款苹果 macOS 工具 - AppleParty(苹果派)
  13. 成都中忻嘉业:抖音怎样查看直播回放
  14. 如何制作独一无二的简历?
  15. 彻底理解傅里叶变换(上)
  16. 华为Linux如何安装微信,华为手机怎么重新安装微信?
  17. 步进伺服电机加减速 及 位置速度控制关键程序
  18. vue3安装wot-design步骤
  19. 任正非:华为要的是全世界
  20. 关于eBPF与可观测性,你想知道的都在这里

热门文章

  1. 在线文本并集计算工具
  2. 解决vue在ie9中的兼容问题
  3. C# 合并多种格式文件为PDF
  4. Facebook人工智能实验室的前世今生
  5. POJ 3988 Selecting courses
  6. Ubuntu上通过 RVM 安装 多版本 Ruby/Rails
  7. Symfony2Book12:HTTP 缓存
  8. 分布式共识算法 (Consensus Algorithm)
  9. c语言程序计算4阶行列式的值,如何用降阶法求解四阶行列式的计算,请帮我编一个C语言程序。...
  10. arduino动态刷新显示_2019 台北电脑展:华硕显示器产品精锐尽出