f85f501bcf3dc771c64f4b2ec7609fc542d4d031

Author
Bartek Pacia <barpac02@gmail.com>
Committer
GitHub <noreply@github.com>
Date

Message

feat(macos): `ofd` now opens any directory (#12337)

Co-authored-by: Carlo Sala <carlosalag@protonmail.com>

Diff

 1diff --git a/plugins/macos/README.md b/plugins/macos/README.md
 2index 1cb9b395d13ce19be090d67dba20bc9e6edfc7aa..2c52ec8a72696db900f2c5d21f671cd9fbb3a5bf 100644
 3--- a/plugins/macos/README.md
 4+++ b/plugins/macos/README.md
 5@@ -17,7 +17,7 @@ Original author: [Sorin Ionescu](https://github.com/sorin-ionescu)
 6 | `tab`         | Open the current directory in a new tab                  |
 7 | `split_tab`   | Split the current terminal tab horizontally              |
 8 | `vsplit_tab`  | Split the current terminal tab vertically                |
 9-| `ofd`         | Open the current directory in a Finder window            |
10+| `ofd`         | Open passed directories (or $PWD by default) in Finder   |
11 | `pfd`         | Return the path of the frontmost Finder window           |
12 | `pfs`         | Return the current Finder selection                      |
13 | `cdf`         | `cd` to the current Finder directory                     |
14diff --git a/plugins/macos/macos.plugin.zsh b/plugins/macos/macos.plugin.zsh
15index a4347005e1e34890287687b9f6f300b02fba7c90..2702a190163c5289901c6b607bf4c1d7a4bf0e75 100644
16--- a/plugins/macos/macos.plugin.zsh
17+++ b/plugins/macos/macos.plugin.zsh
18@@ -3,8 +3,15 @@
19 0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
20 0="${${(M)0:#/*}:-$PWD/$0}"
21 
22-# Open the current directory in a Finder window
23-alias ofd='open_command $PWD'
24+# Open in Finder the directories passed as arguments, or the current directory if
25+# no directories are passed
26+function ofd {
27+  if (( ! $# )); then
28+    open_command $PWD
29+  else
30+    open_command $@
31+  fi
32+}
33 
34 # Show/hide hidden files in the Finder
35 alias showfiles="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"