Last active
March 2, 2020 02:00
-
-
Save hgrimelid/5130e8f4c4fe7d3f7e49 to your computer and use it in GitHub Desktop.
Append to file with Alfred.app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# encoding: utf-8 | |
# Append to file with Alfred.app | |
# A modified version of: http://agiletortoise.com/blog/2013/03/27/mimic-drafts-append-to-dropbox-using-alfred-on-a-mac/ | |
# How to: | |
# | |
# 1. Make sure ActiveSupport is installed: gem install activesupport | |
# | |
# 2. Create a new Alfred workflow from template "Keyboard to Script" or "Keyboard to Script to Notification" | |
# | |
# Log file will be created if it doesn't exist | |
require "active_support/all" # gem install activesupport | |
s = "{query}".mb_chars.normalize # handle non ascii characters | |
# create insert value in template with timestamp | |
tmp = "#{Time.now.strftime('%d.%m.%Y - %H:%M:%S')} - #{s}" | |
# path to file you wish to append... | |
# folder path must exist, file will be created if it doesn't | |
f = File.expand_path("~/Dropbox/Log/log.txt") | |
# open file in append mode and add the string | |
open(f, 'a') do |f| | |
f.puts tmp | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment