]> Sergey Matveev's repositories - nnn.git/commitdiff
Merge pull request #1728 from Xerillic/master
authorArun <engineerarun@gmail.com>
Wed, 20 Sep 2023 12:21:22 +0000 (17:51 +0530)
committerGitHub <noreply@github.com>
Wed, 20 Sep 2023 12:21:22 +0000 (17:51 +0530)
wallpaper plugin: remove unneeded code

.circleci/config.yml
plugins/README.md
plugins/cbcopy-mac [new file with mode: 0755]
plugins/cbpaste-mac [new file with mode: 0755]

index 78ad187ba0242b489385d672a5c9f81059a91789..25628f471bafb08a8f7deac97858db2946c9ab8f 100644 (file)
@@ -66,7 +66,7 @@ jobs:
             echo "########## clang-tidy-15 ##########"
             clang-tidy-15 src/* -- -I/usr/include -I/usr/include/ncursesw
             echo "########## shellcheck ##########"
-            find plugins/ -type f -not -name "*.md" -exec shellcheck {} +
+            find plugins/ -type f ! \( -name "*.md" -o -name "*-mac" \) -exec shellcheck {} +
 
   package-and-publish:
     machine: true
index 167676a1c2eb689299f7cbfff2f6a91bf967ecc5..e20d1bb21b5f44cce71187691c982baea1dc85ee 100644 (file)
@@ -16,6 +16,8 @@ Plugins extend the capabilities of `nnn`. They are _executable_ scripts (or bina
 | [autojump](autojump) | Navigate to dir/path | sh | [jump](https://github.com/gsamokovarov/jump)/autojump/<br>zoxide/z/[z.lua](https://github.com/skywind3000/z.lua) |
 | [boom](boom) | Play random music from dir | sh | [moc](http://moc.daper.net/) |
 | [bulknew](bulknew) | Create multiple files/dirs at once | bash | sed, xargs, mktemp |
+| [cbcopy-mac](cbcopy-mac) | Copy the hovered file to MacOS clipboard | applescript | macos |
+| [cbpaste-mac](cbpaste-mac) | Pastes files from MacOS clipboard into currect directory | macos |
 | [cdpath](cdpath) | `cd` to the directory from `CDPATH` | sh | fzf |
 | [chksum](chksum) | Create and verify checksums [✓] | sh | md5sum,<br>sha256sum |
 | [cmusq](cmusq) | Queue/play files/dirs in cmus player [✓] | sh | cmus, pgrep |
diff --git a/plugins/cbcopy-mac b/plugins/cbcopy-mac
new file mode 100755 (executable)
index 0000000..a117a72
--- /dev/null
@@ -0,0 +1,16 @@
+#!/usr/bin/osascript
+
+# Description: Copy the hovered file to MacOS clipboard.
+#
+# Note: Supports only MacOS
+#
+# Shell: POSIX compliant
+# Author: Syed Umar Anis
+
+
+on run args
+  set filePath to (second item of args & "/" & first item of args)
+  tell application "Finder" 
+    set the clipboard to (filePath as POSIX file)
+  end tell
+end
diff --git a/plugins/cbpaste-mac b/plugins/cbpaste-mac
new file mode 100755 (executable)
index 0000000..51af9e2
--- /dev/null
@@ -0,0 +1,24 @@
+#!/usr/bin/env sh
+# shellcheck disable=all
+
+# Description: Paste the clipboard files into the current directory.
+#              Only works if clipboard contents are files.
+#
+# Note: Supports only MacOS
+#
+# Shell: POSIX compliant
+# Author: Syed Umar Anis
+
+
+fs=($( osascript -e "use framework \"Foundation\"
+    property this : a reference to the current application
+    property NSPasteboard : a reference to NSPasteboard of this
+    property NSURL : a reference to NSURL of this
+    property pb : a reference to NSPasteboard's generalPasteboard
+
+    property text item delimiters : linefeed
+
+    pb's readObjectsForClasses:[NSURL] options:[]
+    (result's valueForKey:\"path\") as list as text" ))
+
+cp -R "${fs[@]}" "$2/"
\ No newline at end of file