In macOS, I’ve configured a variety of shortcuts to automate tasks, for example:
Appending selected text to a specified Obsidian note.
Opening a prompt menu and sharing the selected text with ChatGPT to obtain results.
Extracting text from an image to read in an editor.
And many others.
I frequently use these actions on both my iPhone and Mac. However, on macOS, I find myself having to manually navigate through the Services menu to activate these actions, which tends to slow down my workflow.
To streamline this process, I’ve developed a script that automatically triggers a Services menu item whenever I select text and press Command + Right Click. This enhancement significantly speeds up my interaction with macOS, making my workflow more efficient.
[[Hammerspoon]] script
-- Ensure the listener is global to avoid garbage collection issuesMouseListener=hs.eventtap.new({hs.eventtap.event.types.rightMouseDown},function(e)localbuttonPressed=e:getProperty(hs.eventtap.event.properties.mouseEventButtonNumber)localcmdPressed=e:getFlags().cmdifcmdPressed==truethen-- AppleScript to open the Services menu-- https://stackoverflow.com/a/59330902/22903883hs.osascript.applescript([[
tell application "System Events"
set appName to item 1 of (get name of processes whose frontmost is true)
tell (process 1 where frontmost is true)
tell menu bar 1
tell menu bar item appName
tell menu appName
tell menu item "Services"
tell menu "Services"
click menu item "GPT: Share"
end tell
end tell
end tell
end tell
end tell
end tell
end tell]])returntrue-- Consume the right-right-clickendreturnfalseend)-- Start the event listenerMouseListener:start()
System Prefs / Keyboard / Shortcuts / App Shortcuts / All Applications, click the + button at the bottom, type Emoji & Symbols, and then enter a new keyboard shortcut (option-shift-command-t, or anything really) to free the shortcut
Mac OS intercepts and handles certain key combinations (e.g., - for switching input languages). These will not be passed to Emacs. One can disable this interception by setting mac-pass-command-to-system or mac-pass-control-to-system to nil.
[core]pager=delta[interactive]diffFilter=delta --color-only[delta]navigate=true # use n and N to move between diff sections
light = false # set to true if you're in a terminal w/ a light background color (e.g. the default macOS terminal)[merge]conflictstyle=diff3[diff]colorMoved=default
# Add HomeBrew's bin directory to path so you can use HomeBrew's binaries like `starship`# Fish uses `fish_add_path` instead of `export PATH` modify $PATH.fish_add_path "/opt/homebrew/bin/"# Enable Starship promptstarship init fish |source
abbr proxyall "set --export http_proxy http://127.0.0.1:7890; set --export https_proxy http://127.0.0.1:7890"
custom function
it’s very easy to add a custom function in fish shell,
an example
Visual Studio Code
Settings
Side Bar:Location change to right
extensions
Auto Hide
AutoTrim
Emacs Friendly Keymap
Indenticator
Sort lines
vscode-icons
Python
use
pyenv
to manage Python environments, don’t reply on the python installed by brew, because it might update Python version upexpecetdly when performs brew update.
brew install readline xz pyenv
# otpinal: setup pyenv with fish shellaliasbrew="env PATH=(string replace (pyenv root)/shims '' \"\$PATH\") brew"exec"$SHELL"pyenv install 3.11.6
pyenv global 3.11.6
how to fully reset safari on your mac
for some unknown reason, the Safari option Show Develop menu in menu bar is grayed out and i am unable to click it. Reset the safari according to this article help me solve the issue.