Skip to content

Commit

Permalink
v0.2 - See Changelogs
Browse files Browse the repository at this point in the history
  • Loading branch information
hug33k committed May 25, 2016
1 parent 67d8aa1 commit 27c4877
Show file tree
Hide file tree
Showing 5 changed files with 261 additions and 37 deletions.
26 changes: 20 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,36 @@ Get your shell's variables into Alfred

## Installation

Download [Alfred-ShellVariables.alfredworkflow](https://github.com/hug33k/Alfred-ShellVariables/releases/download/v0.1/Alfred-ShellVariables.alfredworkflow) and open it with Alfred.
Download [Alfred-ShellVariables.alfredworkflow](https://github.com/hug33k/Alfred-ShellVariables/releases/download/v0.2/Alfred-ShellVariables.alfredworkflow) and open it with Alfred.

## Usage

You must start by initialize data by typing "initvar" in Alfred.
Then you can type "$" followed by an optional query to find your shell variables and copy their values into your clipboard.
You must start by selecting your shell with ___sv shell__

Then you can initialize data by typing ___sv init___.

You can now type ___$___, followed by an optional query, to find your shell variables and copy their values into your clipboard.

## Supported shells

- [x] Fish Shell
- [ ] Bash
- [x] Bash
- [ ] ZSH

## TODO

* Add Shell selection
* Bash integration
* ZSH integration

You can make a PR or ask me for integrate another shell :)

## Changelogs

###v0.2

* Add Shell selection
* Rename actions (___sv *___)
* Add Bash support

###v0.1

* Initial release
206 changes: 191 additions & 15 deletions info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<string>Dev</string>
<key>connections</key>
<dict>
<key>65E57995-6ABE-4CD3-A336-6C263E780080</key>
<array/>
<key>90EC00B5-030E-47D2-A490-40514F074398</key>
<array>
<dict>
Expand All @@ -21,6 +23,29 @@
<false/>
</dict>
</array>
<key>921F80D9-092D-4829-B212-7714EA48163A</key>
<array>
<dict>
<key>destinationuid</key>
<string>65E57995-6ABE-4CD3-A336-6C263E780080</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
<dict>
<key>destinationuid</key>
<string>031E6FA5-3C1C-42CA-BE2A-09DCB2E275CF</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
</array>
<key>992FAE5D-93FC-45A2-9E26-1E24A9FD3E82</key>
<array/>
<key>9D0E5065-0318-4297-A0BC-3F55703183AC</key>
Expand All @@ -36,6 +61,19 @@
<false/>
</dict>
</array>
<key>EC6A6E94-CB14-42D3-8982-E6E393525F40</key>
<array>
<dict>
<key>destinationuid</key>
<string>921F80D9-092D-4829-B212-7714EA48163A</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
</array>
</dict>
<key>createdby</key>
<string>Hugo SCHOCH</string>
Expand All @@ -47,6 +85,27 @@
<string>Shell Variables</string>
<key>objects</key>
<array>
<dict>
<key>config</key>
<dict>
<key>lastpathcomponent</key>
<false/>
<key>onlyshowifquerypopulated</key>
<false/>
<key>removeextension</key>
<false/>
<key>text</key>
<string>Copied into your clipboard</string>
<key>title</key>
<string>AlfredShellVar</string>
</dict>
<key>type</key>
<string>alfred.workflow.output.notification</string>
<key>uid</key>
<string>73C7530A-F827-4010-9A51-F404DE6E591D</string>
<key>version</key>
<integer>1</integer>
</dict>
<dict>
<key>config</key>
<dict>
Expand Down Expand Up @@ -110,23 +169,45 @@
<dict>
<key>config</key>
<dict>
<key>lastpathcomponent</key>
<false/>
<key>onlyshowifquerypopulated</key>
<false/>
<key>removeextension</key>
<key>alfredfiltersresults</key>
<false/>
<key>text</key>
<string>Copied into your clipboard</string>
<key>argumenttype</key>
<integer>2</integer>
<key>escaping</key>
<integer>102</integer>
<key>keyword</key>
<string>sv init</string>
<key>queuedelaycustom</key>
<integer>3</integer>
<key>queuedelayimmediatelyinitially</key>
<true/>
<key>queuedelaymode</key>
<integer>0</integer>
<key>queuemode</key>
<integer>1</integer>
<key>runningsubtext</key>
<string>Please wait, initialization in progress</string>
<key>script</key>
<string>python main.py --update</string>
<key>scriptargtype</key>
<integer>0</integer>
<key>scriptfile</key>
<string></string>
<key>subtext</key>
<string></string>
<key>title</key>
<string>AlfredShellVar</string>
<string>Initialize Shell variables</string>
<key>type</key>
<integer>0</integer>
<key>withspace</key>
<false/>
</dict>
<key>type</key>
<string>alfred.workflow.output.notification</string>
<string>alfred.workflow.input.scriptfilter</string>
<key>uid</key>
<string>73C7530A-F827-4010-9A51-F404DE6E591D</string>
<string>992FAE5D-93FC-45A2-9E26-1E24A9FD3E82</string>
<key>version</key>
<integer>1</integer>
<integer>2</integer>
</dict>
<dict>
<key>config</key>
Expand All @@ -138,7 +219,7 @@
<key>escaping</key>
<integer>102</integer>
<key>keyword</key>
<string>initvar</string>
<string>sv shell</string>
<key>queuedelaycustom</key>
<integer>3</integer>
<key>queuedelayimmediatelyinitially</key>
Expand All @@ -150,15 +231,15 @@
<key>runningsubtext</key>
<string>Please wait, initialization in progress</string>
<key>script</key>
<string>python main.py -u</string>
<string>python main.py --shell</string>
<key>scriptargtype</key>
<integer>0</integer>
<key>scriptfile</key>
<string></string>
<key>subtext</key>
<string></string>
<key>title</key>
<string>Initialize Shell variables</string>
<string>Select Shell</string>
<key>type</key>
<integer>0</integer>
<key>withspace</key>
Expand All @@ -167,7 +248,74 @@
<key>type</key>
<string>alfred.workflow.input.scriptfilter</string>
<key>uid</key>
<string>992FAE5D-93FC-45A2-9E26-1E24A9FD3E82</string>
<string>EC6A6E94-CB14-42D3-8982-E6E393525F40</string>
<key>version</key>
<integer>2</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>lastpathcomponent</key>
<false/>
<key>onlyshowifquerypopulated</key>
<false/>
<key>removeextension</key>
<false/>
<key>text</key>
<string>Shell selected</string>
<key>title</key>
<string>AlfredShellVar</string>
</dict>
<key>type</key>
<string>alfred.workflow.output.notification</string>
<key>uid</key>
<string>65E57995-6ABE-4CD3-A336-6C263E780080</string>
<key>version</key>
<integer>1</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>concurrently</key>
<false/>
<key>escaping</key>
<integer>102</integer>
<key>script</key>
<string>python main.py --shell {query}</string>
<key>scriptargtype</key>
<integer>0</integer>
<key>scriptfile</key>
<string></string>
<key>type</key>
<integer>0</integer>
</dict>
<key>type</key>
<string>alfred.workflow.action.script</string>
<key>uid</key>
<string>921F80D9-092D-4829-B212-7714EA48163A</string>
<key>version</key>
<integer>2</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>concurrently</key>
<false/>
<key>escaping</key>
<integer>102</integer>
<key>script</key>
<string>python main.py --update</string>
<key>scriptargtype</key>
<integer>0</integer>
<key>scriptfile</key>
<string></string>
<key>type</key>
<integer>0</integer>
</dict>
<key>type</key>
<string>alfred.workflow.action.script</string>
<key>uid</key>
<string>031E6FA5-3C1C-42CA-BE2A-09DCB2E275CF</string>
<key>version</key>
<integer>2</integer>
</dict>
Expand All @@ -176,6 +324,20 @@
<string></string>
<key>uidata</key>
<dict>
<key>031E6FA5-3C1C-42CA-BE2A-09DCB2E275CF</key>
<dict>
<key>xpos</key>
<integer>610</integer>
<key>ypos</key>
<integer>510</integer>
</dict>
<key>65E57995-6ABE-4CD3-A336-6C263E780080</key>
<dict>
<key>xpos</key>
<integer>610</integer>
<key>ypos</key>
<integer>370</integer>
</dict>
<key>73C7530A-F827-4010-9A51-F404DE6E591D</key>
<dict>
<key>xpos</key>
Expand All @@ -190,6 +352,13 @@
<key>ypos</key>
<integer>110</integer>
</dict>
<key>921F80D9-092D-4829-B212-7714EA48163A</key>
<dict>
<key>xpos</key>
<integer>410</integer>
<key>ypos</key>
<integer>370</integer>
</dict>
<key>992FAE5D-93FC-45A2-9E26-1E24A9FD3E82</key>
<dict>
<key>xpos</key>
Expand All @@ -204,6 +373,13 @@
<key>ypos</key>
<integer>110</integer>
</dict>
<key>EC6A6E94-CB14-42D3-8982-E6E393525F40</key>
<dict>
<key>xpos</key>
<integer>200</integer>
<key>ypos</key>
<integer>370</integer>
</dict>
</dict>
<key>webaddress</key>
<string>http://hug33k.fr</string>
Expand Down
45 changes: 34 additions & 11 deletions init.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,44 @@

import sys
import shell
from workflow import Workflow
from workflow import Workflow, ICON_ERROR

shells = ["fish", "bash"]

def getVariables(shellName):

def fish():
variables = sh.execute(["/usr/local/bin/fish", "-c", "set"])
variables = variables.split("\n")
result = []
for variable in variables:
if len(variable):
tmp = variable.split(" ")
result.append({"name": unicode(tmp[0].decode("utf-8")), "value": unicode(" ".join(tmp[1:]).decode("utf-8"))})
return result

def bash():
variables = sh.execute(["/bin/bash", "-ic", "export"])
variables = variables.split("\n")
result = []
for variable in variables:
if len(variable):
variable = variable.replace("declare -x", "")
tmp = variable.split("=")
result.append({"name": unicode(tmp[0].decode("utf-8")), "value": unicode("=".join(tmp[1:]).decode("utf-8"))})
return result

def getVariables():
sh = shell.Shell()
variables = sh.execute(["/usr/local/bin/fish", "-c", "set"])
variables = variables.split("\n")
result = []
for variable in variables:
if len(variable):
tmp = variable.split(" ")
result.append({"name": unicode(tmp[0].decode("utf-8")), "value": unicode(" ".join(tmp[1:]).decode("utf-8"))})
return result
if shellName in shells:
return locals()[shellName]()

def main(wf):
wf.settings["data"] = getVariables()
try:
wf.settings["data"] = getVariables(wf.settings["shell"])
except:
wf.add_item(title="Missing shell",
subtitle="You should run sv shell",
icon=ICON_ERROR)
wf.send_feedback()

if __name__ == "__main__":
Expand Down
Loading

0 comments on commit 27c4877

Please sign in to comment.