Giter Site home page Giter Site logo

terminal-share's Introduction

This library is no longer being maintained.

terminal-share

macOS Sharing Services... as a Service

Mac OS X 10.8 Mountain Lion introduced built-in sharing as a system-level feature with programmatic access provided via the NSSharingService APIs.

terminal-share extends access to these APIs by proxying through a simple command-line application.

Installation

Install terminal-share by running the following command from Terminal:

$ gem install terminal-share

This will also install the terminal-share executable.

require 'terminal-share'

TerminalShare.share(:twitter, text: "This was shared from the command-line, courtesy of terminal-share, by @mattt", url: "https://github.com/mattt/terminal-share")

Screenshot

Command Line

$ terminal-share -service NAME              \
                [-text text]                \
                [-image /path/to/image]     \
                [-video /path/to/video]     \
                [-url "http://example.com"]

Arguments

  • service: (Required) A short string corresponding to the name of a particular NSSharingService to be used. Available values:
    • twitter - NSSharingServiceNamePostOnTwitter
    • sinaweibo - NSSharingServiceNamePostOnSinaWeibo
    • email - NSSharingServiceNameComposeEmail
    • message - NSSharingServiceNameComposeMessage
    • airdrop - NSSharingServiceNameSendViaAirDrop
    • readinglist - NSSharingServiceNameAddToSafariReadingList
    • iphoto - NSSharingServiceNameAddToIPhoto
    • aperture - NSSharingServiceNameAddToAperture
    • facebook - NSSharingServiceNamePostOnFacebook
    • flickr - NSSharingServiceNamePostImageOnFlickr
    • vimeo - NSSharingServiceNamePostVideoOnVimeo
    • youku - NSSharingServiceNamePostVideoOnYouku
    • tudou - NSSharingServiceNamePostVideoOnTudou
  • text: (optional) Text to be shared.
  • image: (optional) File path to an image to be shared.
  • video: (optional) File path to a video to be shared.
  • url: (optional) URL to be shared.

Not all services support sharing of all types of content. See the NSSharingService Documentation for additional guidelines.

Example

$ terminal-share -service twitter \
                 -text "This was shared from the command-line,  \
                        courtesy of terminal-share, by @mattt"  \
                 -url "https://github.com/mattt/terminal-share"

Creator

Mattt (@mattt)

Credit

Thanks to Eloy Durán for his work on terminal-notifier, which provides a great example of how to use the Script Bridge APIs.

License

terminal-share is available under the MIT license. See the LICENSE file for more info.

terminal-share's People

Contributors

dependabot[bot] avatar jasonp019 avatar maclemon avatar mattt avatar vitorgalvao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

terminal-share's Issues

Auto focus the share window?

I wrote a little script to compose and send the share using your awesome terminal-share library.

Everything works so fine, only a small problem there, I must click the post button to send the share.

In the GUI environment, the share window is auto focused, and the post button is on the default button state. So I just need to hit Ctrl+Shift+D(the pretty old way to send), and the share message is sent.

But, when I start the share window using terminal-share in the iTerm2, the share window seems not focused, every key I typed is sending to the terminal.

Just like the screenshot here:
sina_weibo

Is there any way to make it auto focused, so that I can send the share message using keyboard only.

warning: illegal subclass SHKRemoteView instantiating; client should use only NSRemoteView

On macOS Sierra (10.12.5), on executing

terminal-share -service airdrop file.txt

I'm getting the following message:

2017-07-15 20:05:26.279 _terminal-share[1861:221127] warning: illegal subclass SHKRemoteView instantiating; client should use only
NSRemoteView (
        0   ViewBridge                          0x00007fffe4b79434 -[NSRemoteView _preSuperInit] + 195
        1   ViewBridge                          0x00007fffe4b79793 -[NSRemoteView initWithFrame:] + 25
        2   ShareKit                            0x00007fffe2c45a61 -[SHKRemoteView initWithOptionsDictionary:] + 159
        3   ShareKit                            0x00007fffe2c1fc2d __38-[SHKSharingService performWithItems:]_block_invoke_4 + 1384
        4   libdispatch.dylib                   0x00007fffe69e6524 _dispatch_call_block_and_release + 12
        5   libdispatch.dylib                   0x00007fffe69dd8fc _dispatch_client_callout + 8
        6   libdispatch.dylib                   0x00007fffe69eaaac _dispatch_main_queue_callback_4CF + 925
        7   CoreFoundation                      0x00007fffd12d8bc9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9

        8   CoreFoundation                      0x00007fffd1299c0d __CFRunLoopRun + 2205
        9   CoreFoundation                      0x00007fffd1299114 CFRunLoopRunSpecific + 420
        10  HIToolbox                           0x00007fffd07faebc RunCurrentEventLoopInMode + 240
        11  HIToolbox                           0x00007fffd07facf1 ReceiveNextEventCommon + 432
        12  HIToolbox                           0x00007fffd07fab26 _BlockUntilNextEventMatchingListInModeWithFilter + 71
        13  AppKit                              0x00007fffced93a54 _DPSNextEvent + 1120
        14  AppKit                              0x00007fffcf50f7ee -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:i
nMode:dequeue:] + 2796
        15  AppKit                              0x00007fffced883db -[NSApplication run] + 926
        16  _terminal-share                     0x000000010533db57 _terminal-share + 6999
        17  libdyld.dylib                       0x00007fffe6a13235 start + 1
        18  ???                                 0x0000000000000004 0x0 + 4
)
2017-07-15 20:05:26.285 _terminal-share[1861:221127] warning: <SHKRemoteView: 0x7fd720f12b90> determined it was necessary to config
ure <SHKRemoteViewContainerWindow: 0x7fd720c359d0> to support remote view vibrancy

Crash when sending -service airdrop -text "awesome words I want to send to my mac"

2016-01-16 21:10:43.878 _terminal-share[23331:14155178] error with remoteObjectProxyWithErrorHandler: Error Domain=NSCocoaErrorDomain Code=4097 "connection from pid 23332" UserInfo={NSDebugDescription=connection from pid 23332} 2016-01-16 21:10:43.878 _terminal-share[23331:14155239] plugin com.apple.share.AirDrop.send interrupted

Opens AirDrop window behind everything

What a rad and useful project – thank you!

One kind of frustrating thing I noticed is that the AirDrop window opens behind everything, meaning you have to hide the Terminal first to send the file. Dunno how this works behind the scenes but would love to see that (minor) update!

Sharing window always sit in background (on OS X 10.11)

When I use it on OS X 10.11, the sharing window is always in background (after terminal in z-order), and cannot be switched to foreground.

BTW, how to share a file using AirDrop? Should I use a local URL (file://...)?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.