Jump to content

Virgilius Haufniensis

Member
  • Posts

    6
  • Joined

  • Last visited

Posts posted by Virgilius Haufniensis

  1. Hey, 
    I have a problem, where Alfred loses the ability to search in files. I think I've tried to "rebuild macOS Metadata" six or seven times now, and every time the results is the same: After the reindex has been done, Alfred is able to search for the contents of any document just fine. But within an hour or two, the results gradually disappears until I'm left with a pretty crippled file search.
    E.g. if I search for a term it will show still fewer file results. The order of the files disappearing is always the same. 

    There are no problems whatsoever with searching for the same terms in Spotlight. 

    I search the contents of my pdfs quite often, so it's a vital feature for me. 

  2. Hey everybody!

     

    I am working on this workflow where I have a file filter with the most important text files (for me, at least) to open with vim in iTerm. 

     

    OSTlcQf.png

     

    Currently I have it configured so that I can choose to just run vim and get a new document or I can choose to run "v $SOMEFILE" in Alfred to make it open that way.

     

    w0MRmf1.png

     

    It's super cool, I've used https://github.com/stuartcryan/custom-iterm-applescripts-for-alfred/ and Macvimtoolbox as inspiration for this. There is one bug, however. 

     

    When the active iTerm window is not just showing a prompt but engaged, then the script doesn't open a new windows but just pastes the "nvim /path/to/file" into the window. I'd like to configure the Apple-script to just open a new window in that case. How do I do that? 

     

     

    The code I'm using is here, btw: 

     

    on alfred_script(q) 
    my runIniTerm( "nvim " & q & "" )
    end alfred_script

    -- This is v0.5 of the custom script for AlfredApp for iTerm 2.9+
    -- Please see https://github.com/stuartcryan/custom-iterm-applescripts-for-alfred/
    -- for the latest changes.

    on is_running(app_name)
        tell application "System Events" to (name of processes) contains app_name
    end is_running

    -- Please note, if you store the iTerm binary in any other location than the Applications Folder
    -- please ensure you update the two locations below (in the format of : rather than / for folder dividers)
    -- this gets around issues with AppleScript not handling things well if you have two iTerm binaries on your system... which can happen :D

    on runIniTerm(q)
        if is_running("iTerm2") or is_running("iTerm") then
            run script "
                on run {q}
                    tell application \":Applications:iTerm.app\"
                        activate
                        try
                            select first window
                            set onlywindow to true
                        on error
                            create window with default profile
                            select first window
                            set onlywindow to true
                        end try
                        tell the first window
                            if onlywindow is false then
                                create tab with default profile
                            end if
                            tell current session to write text q
                        end tell
                    end tell
                end run
            " with parameters {q}
        else
            run script "
                on run {q}
                    tell application \":Applications:iTerm.app\"
                        activate
                        try
                            select first window
                        on error
                            create window with default profile
                            select first window
                        end try
                        tell the first window
                            tell current session to write text q
                        end tell
                    end tell
                end run
            " with parameters {q}
        end if
    end runIniTerm

     

    The workflow can be found here:

    https://transfer.sh/Ul5L3/Open-files-with-Vim.alfredworkflow

×
×
  • Create New...