The Bash script is simply this:
Code: Select all
#!/bin/sh
result=$1
/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 pass.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
else
@password_store_dir = `echo $PASSWORD_STORE_DIR`.strip
end
def password_store_contents
contents = `find #{@password_store_dir.to_s} -type f`
contents.gsub("#{@password_store_dir}/", "").gsub(".gpg", "").split(/\n+/)
end
search_results = Array.new
password_store_contents.each do |item|
ARGV.each do |search_query|
search_results.push({
title: "#{item}",
action: "pass.sh",
actionArgument: "#{item}"
}) if item.include? search_query
end
end
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.