isometry Posted March 17, 2013 Share Posted March 17, 2013 (edited) Open man pages with name and section filtering. The 'man' keyword exploits the x-man-page: protocol handler, so will default to opening in Terminal.app but can easily be switched to iTerm2.app. 'hman' opens pages in your default browser, and 'pman' opens PDFs in the default PDF reader. Download / Source Usage man open(1) # open a specific page pman style # open a PDF of the style(9) manpage man open # search all sections for pages matching 'open*' man *open # search all sections for pages matching '*open*' man 2 open # search section 2 for pages with 'open' in the name Enjoy. Edited March 19, 2013 by isometry mdelegge, cjlucas, Tyler Eich and 1 other 4 Link to comment
schoeps Posted March 17, 2013 Share Posted March 17, 2013 I use a similar workflow based on that shell code fragment: man -t {query} | open -f -a Skim as proposed in the Skim FAQ. Maybe somebody else likes this too Link to comment
isometry Posted March 19, 2013 Author Share Posted March 19, 2013 (edited) I use a similar workflow based on that shell code fragment: man -t {query} | open -f -a Skim as proposed in the Skim FAQ. Maybe somebody else likes this too I wasn't keen to rely on additional third-party software. However, I have just updated the workflow with another keyword: 'hman' will open a HTML copy of the man page in Safari; change to Chrome or your browser of choice by tweaking the BROWSER variable at the top of the hman Run Script your default browser. Known issue: some pages aren't rendered properly in HTML (a groff bug?). Any tips on how to fix this gratefully received. Edited March 19, 2013 by isometry Link to comment
isometry Posted March 19, 2013 Author Share Posted March 19, 2013 ...and another update to add the 'pman' keyword to render and open PDF man pages in your default PDF reader. schoeps 1 Link to comment
nikipore Posted March 19, 2013 Share Posted March 19, 2013 Awesome, Robin. More of these, please! Link to comment
twinpeaks Posted March 19, 2013 Share Posted March 19, 2013 Thanks for this and for adding the extra options even though you don't use them. Mighty nice of you! Link to comment
BabylonSix Posted April 17, 2013 Share Posted April 17, 2013 "can easily be switched to iTerm2.app" - How? Link to comment
isometry Posted April 23, 2013 Author Share Posted April 23, 2013 "can easily be switched to iTerm2.app" - How? Something along the following lines should do the job: Create a new profile named "Man Page Handler" (or whatever) Set its command to "/usr/bin/man $$HOST$$" (without the quotes) Select "x-man-page" under "Schemes Handled" Link to comment
ecerulm Posted July 29, 2013 Share Posted July 29, 2013 "can easily be switched to iTerm2.app" - How? Something along the following lines should do the job: Create a new profile named "Man Page Handler" (or whatever) Set its command to "/usr/bin/man $$HOST$$" (without the quotes) Select "x-man-page" under "Schemes Handled" The command I use is /bin/bash -c "/usr/bin/man -S `echo $$HOST$$` `echo $$PATH$$|tr -d /`" since $$HOST$$ is set to the man page section and $$PATH$$ is equal to /command (so the leading / must be stripped ) Link to comment
nikivi Posted December 5, 2015 Share Posted December 5, 2015 Can someone help with this. I tried doing what was said above but it still opens everything in Terminal. How can I make it work? Here is a screencast of me trying to set it up : http://quick.as/b04as8aep If anyone knows a way to fix this, that would be incredible. Thank you for any help. Link to comment
lee_mac Posted March 31, 2016 Share Posted March 31, 2016 Nice! But...it doesn't access stuff installed via MacPorts. In terminal (or iTerm) "man nmap" gets me the manpage for nmap. In Alfred, "man nmap" gets me a 404. Link to comment
deanishe Posted April 1, 2016 Share Posted April 1, 2016 Nice! But...it doesn't access stuff installed via MacPorts. In terminal (or iTerm) "man nmap" gets me the manpage for nmap. In Alfred, "man nmap" gets me a 404. You probably need to make sure MANPATH is set in the workflow. Link to comment
lee_mac Posted April 1, 2016 Share Posted April 1, 2016 You probably need to make sure MANPATH is set in the workflow. In the workflow? MANPATH is set export MANPATH=/opt/local/share/man:$MANPATH) and works in iTerm2 and Terminal. How do I add it to the workflow? Link to comment
deanishe Posted April 1, 2016 Share Posted April 1, 2016 In the workflow? MANPATH is set export MANPATH=/opt/local/share/man:$MANPATH) and works in iTerm2 and Terminal. How do I add it to the workflow? Dunno, tbh. I'd add it to /etc/manpaths instead. Can you find the man page for any MacPort program? If you've just installed nmap, it's also possible that the manpage index simply hasn't been updated yet. Updating the indices might help. Try: sudo /usr/libexec/makewhatis You'll also need to delete the workflow's cache files in ~/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/net.isometry.alfred.man/ so it re-reads the indices. Finally, it's also possible that you need to enter Nmap, not nmap. Link to comment
lee_mac Posted April 1, 2016 Share Posted April 1, 2016 - path is in /etc/manpaths - reindexed - cleared Alfred/Workflow cache (didn't do that before...had high hopes) - Tried nmap and Nmap Still not working. I tried several (of course not all) ports (some of them installed for ages, others recently) in iTerm2 with man. nmap, bonnie, iozone, htop....they all work, but none with the Alfred workflow. Dunno, tbh. I'd add it to /etc/manpaths instead. Can you find the man page for any MacPort program? If you've just installed nmap, it's also possible that the manpage index simply hasn't been updated yet. Updating the indices might help. Try: sudo /usr/libexec/makewhatis You'll also need to delete the workflow's cache files in ~/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/net.isometry.alfred.man/ so it re-reads the indices. Finally, it's also possible that you need to enter Nmap, not nmap. Link to comment
deanishe Posted April 1, 2016 Share Posted April 1, 2016 Do the programs appear when you run: man -k -Pcat . That dumps a list of all man files. Link to comment
lee_mac Posted April 1, 2016 Share Posted April 1, 2016 Interesting...they don't. Apparently "man -k -Pcat ." dumps the man pages from OSX while man also accesses the MacPorts man pages.... Neither nmap, bonnie, htop, aria2c appear in the dump but man works with them... Do the programs appear when you run: man -k -Pcat . That dumps a list of all man files. Link to comment
deanishe Posted April 1, 2016 Share Posted April 1, 2016 (edited) So it's your man command that's not working properly, not the workflow. Is there a whatis file in the MacPorts man directory? That's the index man -k (and apropos and whatis) uses. The plain man command doesn't use the index. That's why it works when -k doesn't. Edited April 1, 2016 by deanishe Link to comment
tschloss Posted February 21, 2018 Share Posted February 21, 2018 IS this considered solved? My installation does not work (latest OS, latest Alfred 3, latest workflow). This is the debug log when typing "man g" into Alfred: Starting debug for 'man' [2018-02-21 10:04:37][ERROR: input.scriptfilter] Code 1: Traceback (most recent call last): File "<string>", line 2, in <module> File "alfredman.py", line 80, in complete whatis = fetch_whatis() File "alfredman.py", line 20, in fetch_whatis cache = path.join(alfred.work(volatile=True), u'whatis.1.json') File "alfred.py", line 70, in work return _create(os.path.join(os.path.expanduser(path), bundleid)) File "alfred.py", line 83, in _create os.mkdir(path)OSError: [Errno 2] No such file or directory: '/Users/tschloss/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/net.isometry.alfred.man' Any suggestions? I am not able to heal it myself. Thank you Thomas Link to comment
deanishe Posted February 21, 2018 Share Posted February 21, 2018 22 minutes ago, tschloss said: Any suggestions? I am not able to heal it myself. The problem is that this workflow has Alfred 2's directories hardcoded, but your system doesn't have them because you're using Alfred 3. Going by the error, the workflow uses the alfred.py library. You should open that file in an editor and change Alfred-2 and Alfred 2 to Alfred-3 and Alfred 3 respectively. Link to comment
tschloss Posted February 21, 2018 Share Posted February 21, 2018 Great! Thank you - it worked. I found a lot of workflows with exactly the same problem in my installation. Best Thomas Link to comment
deanishe Posted February 21, 2018 Share Posted February 21, 2018 In that case, an easier solution might be to create the Alfred 2 directories they're expecting to find. I never deleted mine for the same reason. It's a lot easier than fixing a dozen or more workflows. Link to comment
gingerbeardman Posted January 10, 2020 Share Posted January 10, 2020 This has stopped working for me in a recent version of Alfred? man<space> gets me the menu item but any further typing sees it go away and i can therefore not get any useful results. Screen recording: https://imgur.com/a/neDNArt Link to comment
Vero Posted January 10, 2020 Share Posted January 10, 2020 @gingerbeardman Could you please share which version of Alfred, macOS and any dependencies of the workflow you're using? Also, when you look at the debug log, what do you see? https://www.alfredapp.com/help/workflows/advanced/debugger/ Cheers, Vero Link to comment
Terminal Posted January 10, 2020 Share Posted January 10, 2020 43 minutes ago, gingerbeardman said: This has stopped working for me in a recent version of Alfred? man<space> gets me the menu item but any further typing sees it go away and i can therefore not get any useful results. Screen recording: https://imgur.com/a/neDNArt I am guessing it is the same issue that I encountered. Open up alfredman.py and replace lines 29 - 33 with the following for info in pagelist: if len(info) != 2: continue for item in info[0].split(', '): whatis[item] = info[1] json.dump(whatis, open(cache, 'w')) return whatis Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now