Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue that no directory appears #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yamitzky
Copy link

Fix problem on the following situation;

  • only one directory is returned by autojump.
  • directory includes non-ascii string like Japanese string.

My problem is fixed, but I am not sure that issue #2 is also fixed.

Here's python code in autojump.alfredworkflow;

import commands
import re
import os
from feedback import Feedback

IMG = os.path.join('autojump', 'bin', 'icon.png')
AUTOJUMP = os.path.join('autojump', 'bin', 'autojump')
COMMAND = '%s --complete %s'

query = '{query}'
fb = Feedback()

directories = commands.getoutput(COMMAND % (AUTOJUMP, query))

if directories:
    candidates = directories.split('\n')
    for dir in candidates:
        match = re.match(r'^(.+?)__[1-9]__(?P<path>/.+)$', dir)
        if match:
            path = match.group('path')
        else:
            path = dir
        path = path.decode('utf8')
        fb.add_item("Open %s" % path, arg=path, icon=IMG)
    print fb
else:
    stats = commands.getoutput('autojump/bin/autojump -s')
    candidates = reversed(stats.split('\n'))
    for dir in candidates:
        match = re.match(r'^\d+\.\d:\s+(?P<path>/.+)$', dir)
        if match:
            path = match.group('path').decode('utf8')
            fb.add_item('Open %s' % path, arg=path, icon=IMG)
    print fb

Fix problem on the following situation;

- only one directory is returned by autojump.
- directory includes non-ascii string like Japanese string.
@giginet
Copy link
Owner

giginet commented May 31, 2015

@yamitzky Thanks for your contribution 😄

I tried this PR, however it seems to not work.

I'm going to re-create this plugin.
Just a moment, please. 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants