 
 cmds.extend defaultCommands
 
+cacheCompletions = (str) ->
+  cacheFile = path.join(config.getDataDir(), "bash_completions")
+  str ?= (cmd._name for cmd in commander.commands when cmd._name isnt "*").join(" ")
+  oldStr = (if fs.existsSync(cacheFile) then fs.readFileSync cacheFile, "utf8" else null)
+  fs.writeFileSync cacheFile, str, "utf8" if str != oldStr
 
 # check for private commands first (start with underscore)
 if process.argv.length == 3


  # eval "$(./app.js init)"
  init: () ->
    console.log """
    function _qdwrap() {
      local cmd newPath

    programDone()

  _bash_complete: () ->
    str = (cmd._name for cmd in commander.commands when cmd._name isnt "*").join(" ")
    console.log str
    cacheCompletions str
    programDone()

  _cd: () ->
