1
0
Fork 0
forked from mirror/nnn

plugins for integration with MacOS clipboard

This commit is contained in:
umaranis 2023-09-08 05:39:06 +10:00 committed by Arun Prakash Jana
parent 547508aa78
commit a06af824ee
No known key found for this signature in database
GPG key ID: 4A865183AF6C5631
4 changed files with 43 additions and 1 deletions

View file

@ -66,7 +66,7 @@ jobs:
echo "########## clang-tidy-15 ##########" echo "########## clang-tidy-15 ##########"
clang-tidy-15 src/* -- -I/usr/include -I/usr/include/ncursesw clang-tidy-15 src/* -- -I/usr/include -I/usr/include/ncursesw
echo "########## shellcheck ##########" 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: package-and-publish:
machine: true machine: true

View 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) | | [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/) | | [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 | | [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 | | [cdpath](cdpath) | `cd` to the directory from `CDPATH` | sh | fzf |
| [chksum](chksum) | Create and verify checksums [✓] | sh | md5sum,<br>sha256sum | | [chksum](chksum) | Create and verify checksums [✓] | sh | md5sum,<br>sha256sum |
| [cmusq](cmusq) | Queue/play files/dirs in cmus player [✓] | sh | cmus, pgrep | | [cmusq](cmusq) | Queue/play files/dirs in cmus player [✓] | sh | cmus, pgrep |

16
plugins/cbcopy-mac Executable file
View file

@ -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

24
plugins/cbpaste-mac Executable file
View file

@ -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/"