Created
March 30, 2012 12:50
-
-
Save Donearm/2251304 to your computer and use it in GitHub Desktop.
Open a url with feh, if it leads to an image, or firefox, in all other cases
This file contains hidden or 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
#!/usr/bin/env lua | |
--- | |
-- @author Gianluca Fiore | |
-- @copyright 2012, Gianluca Fiore <[email protected]> | |
-- | |
-- | |
-- Open a url with feh, if it leads to an image, or firefox, in all | |
-- other cases. Trivial but very useful with cli newsreaders (like | |
-- newsbeuter) to quickly preview images and to not have to switch to | |
-- the browser's desktop for every url | |
-- Regexp for images | |
local rImages = ".*%.[jJGgpP][pPiInN][eE]?[gGfF]" | |
-- exit if not arguments given | |
if not arg[1] then | |
os.exit(1) | |
end | |
if string.match(arg[1], rImages) then | |
local f = os.execute('feh ' .. arg[1]) | |
os.exit(0) | |
else | |
local b = os.execute('firefox ' .. arg[1]) | |
os.exit(0) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment