Skip to content

Commit

Permalink
plugins for integration with MacOS clipboard
Browse files Browse the repository at this point in the history
  • Loading branch information
umaranis committed Sep 7, 2023
1 parent 547508a commit 4ae5ff3
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions plugins/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
16 changes: 16 additions & 0 deletions plugins/cbcopy-mac
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions plugins/cbpaste-mac
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env sh

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

0 comments on commit 4ae5ff3

Please sign in to comment.