-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
299 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Publish Alfred Workflow | ||
|
||
on: | ||
push: | ||
tags: | ||
- "*" | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Build project | ||
run: make pip | ||
- name: Build Alfred Workflow | ||
id: alfred_builder | ||
uses: mperezi/build-alfred-workflow@v1 | ||
with: | ||
workflow_dir: "." | ||
exclude_patterns: ".git/* .github/* *.pyc *__pycache__/*" | ||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: ${{ github.ref }} | ||
draft: false | ||
prerelease: false | ||
- name: Upload Alfred Workflow | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ${{ steps.alfred_builder.outputs.workflow_file }} | ||
asset_name: ${{ steps.alfred_builder.outputs.workflow_file }} | ||
asset_content_type: application/zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
lib/ | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# See https://pre-commit.com for more information | ||
# See https://pre-commit.com/hooks.html for more hooks | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v2.5.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer | ||
- repo: https://github.com/prettier/prettier | ||
rev: master | ||
hooks: | ||
- id: prettier |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
printWidth: 80 | ||
trailingComma: "es5" | ||
useTabs: false | ||
tabWidth: 2 | ||
semi: false | ||
singleQuote: false | ||
endOfLine: "lf" | ||
proseWrap: "always" | ||
overrides: | ||
- files: "*.yaml" | ||
options: | ||
proseWrap: "preserve" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
SRC := main.py info.plist lib icon.png | ||
WF_DIR := ${HOME}/Documents/Alfred/Alfred.alfredpreferences/workflows/alfred-sshconfig | ||
VERSION := $(shell grep -Eo 'string.*[0-9]+\.[0-9]+\.[0-9]+.*string' info.plist | cut -d">" -f2 | cut -d"<" -f1) | ||
|
||
all: pip link | ||
|
||
pip: | ||
python2 -m pip install --upgrade pip | ||
python2 -m pip install --target=./lib -r _requirements.txt | ||
|
||
link: | ||
mkdir -p "${WF_DIR}" | ||
for f in ${SRC} ; do \ | ||
ln -sf "${PWD}/$$f" "${WF_DIR}/$$f"; \ | ||
done | ||
|
||
clean: | ||
for f in ${SRC} ; do \ | ||
unlink "${WF_DIR}/$$f"; \ | ||
done | ||
|
||
release: | ||
git tag ${VERSION} | ||
git push origin ${VERSION} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
### Installation | ||
|
||
[Download](https://github.com/fbjorn/alfred-sshconfig/releases/) Alfred workflow | ||
and open it | ||
|
||
### Usage | ||
|
||
Invoke Alfred and type `ssh` | ||
|
||
Hosts from `~/.ssh/config` are parsed and prompted to the output. Choose | ||
required one (fuzzy search supported) and press enter. | ||
|
||
Alfred will open new tab in iTerm2 and will connect you to the host. | ||
|
||
### Local development | ||
|
||
```bash | ||
make | ||
``` | ||
|
||
It will create a `alfred-sshconfig` folder in your default Alfred installation | ||
and add all required source files as symlinks. | ||
|
||
Then just open Alfred on Workflows tab and you'll find it. | ||
|
||
--- | ||
|
||
Made with [Alfred-Workflow](https://github.com/deanishe/alfred-workflow) | ||
|
||
Bootstrapped from | ||
[alfred-python-template](https://github.com/fbjorn/alfred-python-template) | ||
|
||
Icons made by [Freepik](https://www.flaticon.com/authors/freepik) from | ||
[Flaticon](https://www.flaticon.com/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Alfred-Workflow==1.40.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# encoding: UTF-8 | ||
import os | ||
import re | ||
import sys | ||
|
||
sys.path.append("lib") # noqa | ||
|
||
from lib.workflow import Workflow3, Workflow | ||
|
||
|
||
def get_hosts(): | ||
path = os.path.join(os.path.expanduser("~"), ".ssh", "config") | ||
with open(path) as f: | ||
conf = f.read() | ||
hosts = re.findall(r"[\t ]*?Host[\t ]+?(.+)$", conf, re.MULTILINE) | ||
return hosts | ||
|
||
|
||
def main(wf): | ||
# type: (Workflow) -> int | ||
|
||
query = "" | ||
if len(wf.args): | ||
query = wf.args[0] | ||
|
||
hosts = wf.cached_data("hosts", get_hosts, max_age=10) | ||
hosts = wf.filter(query, hosts) | ||
for host in hosts: | ||
wf.add_item(title=host, valid=True, arg=host) # TODO: Add IP and user/keypair | ||
|
||
wf.send_feedback() | ||
return 0 | ||
|
||
|
||
if __name__ == "__main__": | ||
workflow = Workflow3() | ||
sys.exit(workflow.run(main)) |