summaryrefslogtreecommitdiff
path: root/plugins/macos
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/macos')
-rw-r--r--plugins/macos/README.md13
-rw-r--r--plugins/macos/macos.plugin.zsh52
2 files changed, 59 insertions, 6 deletions
diff --git a/plugins/macos/README.md b/plugins/macos/README.md
index 1cb9b395d..ccc4331e5 100644
--- a/plugins/macos/README.md
+++ b/plugins/macos/README.md
@@ -8,7 +8,12 @@ To start using it, add the `macos` plugin to your plugins array in `~/.zshrc`:
plugins=(... macos)
```
-Original author: [Sorin Ionescu](https://github.com/sorin-ionescu)
+## Supported Terminals
+- [iTerm](https://iterm.sourceforge.net/)
+- [iTerm2](https://iterm2.com/)
+- [Hyper](https://hyper.is/)
+- [Tabby](https://tabby.sh/)
+- [Ghostty](https://ghostty.org)
## Commands
@@ -17,7 +22,7 @@ Original author: [Sorin Ionescu](https://github.com/sorin-ionescu)
| `tab` | Open the current directory in a new tab |
| `split_tab` | Split the current terminal tab horizontally |
| `vsplit_tab` | Split the current terminal tab vertically |
-| `ofd` | Open the current directory in a Finder window |
+| `ofd` | Open passed directories (or $PWD by default) in Finder |
| `pfd` | Return the path of the frontmost Finder window |
| `pfs` | Return the current Finder selection |
| `cdf` | `cd` to the current Finder directory |
@@ -37,7 +42,9 @@ Original author: [Sorin Ionescu](https://github.com/sorin-ionescu)
## Acknowledgements
-This application makes use of the following third party scripts:
+Original author: [Sorin Ionescu](https://github.com/sorin-ionescu)
+
+This application makes use of the following third-party scripts:
[shpotify](https://github.com/hnarayanan/shpotify)
diff --git a/plugins/macos/macos.plugin.zsh b/plugins/macos/macos.plugin.zsh
index e27d412c8..4d73d22c3 100644
--- a/plugins/macos/macos.plugin.zsh
+++ b/plugins/macos/macos.plugin.zsh
@@ -3,8 +3,15 @@
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
0="${${(M)0:#/*}:-$PWD/$0}"
-# Open the current directory in a Finder window
-alias ofd='open_command $PWD'
+# Open in Finder the directories passed as arguments, or the current directory if
+# no directories are passed
+function ofd {
+ if (( ! $# )); then
+ open_command $PWD
+ else
+ open_command $@
+ fi
+}
# Show/hide hidden files in the Finder
alias showfiles="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
@@ -72,6 +79,19 @@ EOF
key code 36 #(presses enter)
end tell
EOF
+
+ elif [[ "$the_app" == 'Tabby' ]]; then
+ osascript >/dev/null <<EOF
+ tell application "System Events"
+ tell process "Tabby" to keystroke "t" using command down
+ end tell
+EOF
+ elif [[ "$the_app" == 'ghostty' ]]; then
+ osascript >/dev/null <<EOF
+ tell application "System Events"
+ tell process "Ghostty" to keystroke "t" using command down
+ end tell
+EOF
else
echo "$0: unsupported terminal app: $the_app" >&2
return 1
@@ -120,6 +140,18 @@ EOF
keystroke "${command} \n"
end tell
EOF
+ elif [[ "$the_app" == 'Tabby' ]]; then
+ osascript >/dev/null <<EOF
+ tell application "System Events"
+ tell process "Tabby" to keystroke "D" using command down
+ end tell
+EOF
+ elif [[ "$the_app" == 'ghostty' ]]; then
+ osascript >/dev/null <<EOF
+ tell application "System Events"
+ tell process "Ghostty" to keystroke "D" using command down
+ end tell
+EOF
else
echo "$0: unsupported terminal app: $the_app" >&2
return 1
@@ -169,6 +201,18 @@ EOF
keystroke "${command} \n"
end tell
EOF
+ elif [[ "$the_app" == 'Tabby' ]]; then
+ osascript >/dev/null <<EOF
+ tell application "System Events"
+ tell process "Tabby" to keystroke "d" using command down
+ end tell
+EOF
+ elif [[ "$the_app" == 'ghostty' ]]; then
+ osascript >/dev/null <<EOF
+ tell application "System Events"
+ tell process "Ghostty" to keystroke "d" using command down
+ end tell
+EOF
else
echo "$0: unsupported terminal app: $the_app" >&2
return 1
@@ -224,8 +268,10 @@ function quick-look() {
}
function man-preview() {
+ [[ $# -eq 0 ]] && >&2 echo "Usage: $0 command1 [command2 ...]" && return 1
+
local page
- for page in "${(@f)"$(man -w $@)"}"; do
+ for page in "${(@f)"$(command man -w $@)"}"; do
command mandoc -Tpdf $page | open -f -a Preview
done
}