Show HN: A programmable tooltip on Mac OS
tanin.nanakorn.com
tanin.nanakorn.com
I use the builtin `date` utility for this specific task, instead of querying another webpage to translate it.
$ date -r 1577733633
Mon Dec 30 20:20:33 CET 2019 date -r 1577733633
date: 1577733633: No such file or directory
... -r, --reference=FILE
display the last modification time of FILE
...Is OSX's date command different from Linux?
$ date -r 1577733633 | pbcopyVery interesting solution for text manipulation. (A bit off topic but...) Seeing these tools which primary interaction happens with the clipboard make me think that the GUI equivalent of UNIX pipes is the clipboard — it allows programs to interoperate in an unstructured fashion.
[0]: https://pilotmoon.com/popclip/
[edit]: fixed typo & changed some words to convey my meaning better.
Tip is less intrusive and targets programmers (because your provide the script). PopClip is more out-of-the-box and more automatic (I assume PopClip monitors mouse events, but not sure).
I wanted to build Tip for Ubuntu as well but I couldnt find a good mechanism. Mac OS's system-wide service is such a beautiful mechanism. Slick and offer the right level of privacy.
Quick note on text manipulation. Mac's system-wide service can modify text as well!... But sadly I couldn't make it work in a slick way. I might need to attempt at it again
The selected text would already be on the 'PRIMARY' uh.. clipboard (I hesitate because that's not the 'CLIPBOARD' one and I'm not sure of the genetic term). I would then use dmenu (or equivalent, e.g. rofi) to show the options generated by the script running on the selection.
That wouldn't be a tooltip, (unless there are dmenu-like programs that can be configured to appear at the pointer, I'm not sure) but is probably how most Linux users would expect/want it to appear.
To be honest though, since the target user is already supplying the script to generate it, I think you've given the value you can in the idea, and they're best placed to know how to integrate it into their existing tools most effectively.
For example, using i3 & dmenu:
bindsym <shortcut keys> exec xsel | thescript.sh | dmenu
If the user's writing the script anyway, they can write that, and the details vary according to the window manager (or other tool used to bind keys) and the dmenu-like used to display them. Some may also prefer a different/better integration with their clipboard manager.My basic point is that Linux systems are too 'fragmented' and this is too easy for you to a better job once for everybody than they can each do once for themselves.
It's a great idea though, I'm certainly going to bear it in mind and see what I do that could benefit from it, thanks!
The idea is very interesting. Basically, I only build the part where Tip takes the text and invokes a script. User then renders the tooltip themselves.
Thank you!
While I'm on this topic, let me add that Lua is way faster than Python or even JS, so it enhances the responsiveness if used for workflow scripts or ‘script filters’.
I'm also using the Automate app on Android to very similar ends: it can have your workflows invoked via the text selection menu or through sharing (no addons with more payment and embedded ads code necessary, like with Tasker).
IIRC some version of Keepass cleared passwords from the clipboard in such a way that even clipboard-history apps obeyed—but can't remember if this was in OSX or Linux. I wonder if this method could be used to pop the previous content back on the clipboard and leave no trace of the selection in the history.
Currently, I have to: - sign in to AWS SSO - choose an account - copy the ENV VARs to my clipboard - select an iTerm2 tab - paste ENV VARs into the tab
Using 'tip' I think I could automated the last 3 steps. It's a small win, but when you do it multiple times a day it adds up.
One of tooltip item actions is opening URL.
I'm not sure if iTerm2 supports executing stuff through URL. (For example, we can open intellij using idea://.)
If not possible, please open a GitHub issue or reply here. We can figure it out together. We might be able to get Tip to support triggering iTerm2 somehow natively.
Thank you sharing an interesting use case!
function aws_switch () {
local env="$1"
local region="$2"
export AWS_DEFAULT_PROFILE="$env"
export AWS_ENV="$env"
export KITCHEN_ENV="$env"
export AWS_ACCESS_KEY_ID=$(/usr/bin/env ruby -e "require 'inifile'; puts IniFile.load(File.join(File.expand_path('~'), '.aws', 'credentials'))[ENV['AWS_DEFAULT_PROFILE']]['aws_access_key_id']")
export AWS_SECRET_ACCESS_KEY=$(/usr/bin/env ruby -e "require 'inifile'; puts IniFile.load(File.join(File.expand_path('~'), '.aws', 'credentials'))[ENV['AWS_DEFAULT_PROFILE']]['aws_secret_access_key']")
if [ -z "$region" ]
then
export AWS_REGION=$(/usr/bin/env ruby -e "require 'inifile'; puts IniFile.load(File.join(File.expand_path('~'), '.aws', 'config'))['profile ' + ENV['AWS_DEFAULT_PROFILE']]['region']")
else
export AWS_REGION="$region"
fi
export AWS_DEFAULT_REGION=$AWS_REGION
}I'm just typing the 1Password password on the terminal, I could automate that part too but then essentially I'm removing all auth from my workflow which is dangerous especially on laptops.
I think it's called (or was called at some point) "system-wide services". But official doc doesn't use this term.
I was simply fortunate to stumble upon it. Initially, I was thinking about building Tip on clipboard (or pasteboard), which would have been inferior.
These aren’t simply tool tips. They are actions.
Tip shows related actions that can be performed on a piece of text.
A suggestion is very welcome here.
Also, regarding Swift, the language is pretty simple: I did't know either ObjC or Swift but was able to make a small program in it. The most annoying thing is that Swift's APIs and types constantly change between versions, so you have to translate between the docs and your version of OSX.
Yes, Right clicking and selecting the menu manually works as well. Thank you for mentioning it.
My setting is that my mouse has an extra button, so I configure the extra mouse button to emit Cmd+F3 (which triggers Tip). It's a one-hand one-click operation!
The fundamental of Tip is that every piece of text has a relevant set of actions.
I have two questions:
1. Did you decide against including any script in the app bundle for more privacy? It looks like it.
2. So all scripts must be appended in that same file? Have you thought about a behavior like a ".d" directory in the recent "Unix world", where each file can add configuration options? That would enable using different scripts and different languages.
Sorta.
My initial use case didn't need a bundled script. My current script involves heavily my local env (e.g. credentials, searching local file). Some use cases are very specific to company's internals (e.g. lookup user id).
I might consider embed a script. But I haven't given it much thought yet, and, because of App Sandbox, the script wouldn't be able to do much.
> 2. So all scripts must be appended in that same file? Have you thought about a behavior like a ".d" directory in the recent "Unix world", where each file can add configuration options? That would enable using different scripts and different languages.
Yes, that's some what in a roadmap. For now, you can workaround by having the main script calls out to the other script
Thank you for the questions. Please don't hesitate to let me know how it works for you!
For a lot of my personal productivity tools, I've been using Alfred, but for some of them a tooltip would be a lot more natural. Looking forward to using it!
Otherwise, PopClip would be a great out-of-the-box alternative.