@@ -71,7 +71,8 @@ import qualified Data.Text as T
7171import Control.Applicative ((<$>), (<|>))
7272import Text.Pandoc.Readers.Txt2Tags (getT2TMeta)
7373import Data.Monoid
74−
74+import Paths_pandoc (getDataDir)
75+import Text.Printf (printf)
7576import Text.Pandoc.Error
7677
7778type Transform = Pandoc -> Pandoc
@@ -880,6 +881,22 @@ options =
880881 (\opt -> return opt { optVerbose = True }))
881882 "" -- "Verbose diagnostic output."
882883
884+ , Option "" ["bash-completion"]
885+ (NoArg
886+ (\_ -> do
887+ ddir <- getDataDir
888+ tpl <- readDataFileUTF8 Nothing "bash_completion.tpl"
889+ let optnames (Option shorts longs _ _) =
890+ map (\c -> ['-',c]) shorts ++
891+ map ("--" ++) longs
892+ let allopts = unwords (concatMap optnames options)
893+ UTF8.hPutStrLn stdout $ printf tpl allopts
894+ (unwords (map fst readers))
895+ (unwords ("pdf": map fst writers))
896+ ddir
897+ exitWith ExitSuccess ))
898+ "" -- "Print bash completion script"
899+
883900 , Option "v" ["version"]
884901 (NoArg
885902 (\_ -> do