Passing item to action "" script with terminal command not working

Sharing and discussing custom actions for LaunchBar
Posts: 6
Joined: Thu Oct 29, 2015 9:19 pm

Passing item to action "" script with terminal command not working

Postby benjaminwil » Fri Aug 24, 2018 5:39 pm

I'm making a LaunchBar action with Ruby. My default.rb code seems complete, and I can successfully pass an item to another script, which is a Bash script. I have already chmoded it to executable.

The Bash script is simply this:

Code: Select all


/usr/local/bin/pass -c $result

The pass -c argument copies a password in my password store to the clipboard for 48 seconds.

I can successfully run this script manually in my terminal (sh argument). When I do this, the password is attached to the clipboard.

If I do not pass my default.rb script to the Bash script, the rest of my script runs successfully.

When I run it through LaunchBar, I always am told to see Console for error messages. None of them are very descriptive.

I would be interested in using the LaunchBar JavaScript functions instead of a Bash script, but when I pass my Ruby script to a JavaScript script, a LaunchBar dialog box always tells me "The script is invalid."

Here is my default.rb script for reference:

Code: Select all

#!/usr/bin/env ruby

require 'json'

if `echo $PASSWORD_STORE_DIR` == "\n"
  @password_store_dir = `echo $HOME/.password-store`.strip
  @password_store_dir = `echo $PASSWORD_STORE_DIR`.strip

def password_store_contents
  contents = `find #{@password_store_dir.to_s} -type f`
  contents.gsub("#{@password_store_dir}/", "").gsub(".gpg", "").split(/\n+/)

search_results =

password_store_contents.each do |item|
  ARGV.each do |search_query|
      title: "#{item}",
      action: "",
      actionArgument: "#{item}"
    }) if item.include? search_query

puts search_results.to_json

I would *super* appreciate *any* help with this, of course. Even if you don't have a full-out solution for me.

If necessary, I will port all my Ruby to JavaScript, too.

Let me know if I can provide any other information.

Return to “LaunchBar Actions”

Who is online

Users browsing this forum: No registered users and 1 guest