mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-02-06 02:51:32 +01:00
add file filepicker plugin by @rhacker
This commit is contained in:
parent
b34aee7f76
commit
eb90543fd6
2 changed files with 40 additions and 0 deletions
2
plugins/filepicker/filepicker.plugin.zsh
Normal file
2
plugins/filepicker/filepicker.plugin.zsh
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
#!/bin/zsh
|
||||||
|
alias filepicker=$ZSH/plugins/filepicker/filepicker.rb
|
||||||
38
plugins/filepicker/filepicker.rb
Executable file
38
plugins/filepicker/filepicker.rb
Executable file
|
|
@ -0,0 +1,38 @@
|
||||||
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
|
require 'rubygems'
|
||||||
|
|
||||||
|
# check required gems
|
||||||
|
['json'].each do |gem|
|
||||||
|
begin
|
||||||
|
require gem
|
||||||
|
rescue LoadError
|
||||||
|
puts "You need to install #{gem}: gem install #{gem}"
|
||||||
|
exit!(1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# read api key
|
||||||
|
config_file = "#{ENV['HOME']}/.filepicker"
|
||||||
|
unless File.exist?(config_file)
|
||||||
|
puts "You need to type your API key " + config_file
|
||||||
|
exit!(1)
|
||||||
|
end
|
||||||
|
api_key = File.read(config_file)
|
||||||
|
|
||||||
|
# checking input file
|
||||||
|
if ARGV[0].nil?
|
||||||
|
puts "You need to specify a file to upload."
|
||||||
|
exit!(1)
|
||||||
|
end
|
||||||
|
|
||||||
|
# upload
|
||||||
|
file_name = ARGV[0]
|
||||||
|
json_return = `curl -s -F fileUpload=@#{file_name} 'https://www.filepicker.io/api/store/S3?key=#{api_key}&filename=#{file_name}'`
|
||||||
|
url = JSON.parse(json_return)['url']
|
||||||
|
|
||||||
|
# output to consle the link
|
||||||
|
puts url
|
||||||
|
|
||||||
|
# copy to mac clipboard
|
||||||
|
`echo #{url} | pbcopy`
|
||||||
Loading…
Add table
Add a link
Reference in a new issue