def html2jade(html): try: default = open(expand_path("~/.nvm/alias/default")).read().strip() except: return "nvm is not set up for html2jade on this machine" node_root = os.path.join("~/.nvm/versions/node/", default) node_root = expand_path(node_root) args = [ os.path.join(node_root, "bin/node"), os.path.join(node_root, "bin/html2jade"), "--double", "--noattrcomma", "--bodyless", "--donotencode", "-" ] popen = subprocess.Popen( args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE ) (jade, stderr) = popen.communicate(html) if stderr: sys.stderr.write("ERROR: %s" % stderr) return print("copying jade onto the clipboard\n" + jade) return jade
def new_daily_routine(): dr_path = "/tmp/daily_routine.md" shutil.copyfile( expand_path(DAILY_ROUTINE_PATH), dr_path ) editor(dr_path)
def snippet(input): abbreviation = input.split(" ")[0] phrase = input[len(abbreviation) + 1:] if not phrase: phrase = commander.mac.pbpaste() snippet_path = expand_path( "~/projects/snippets/%s" % abbreviation) with open(snippet_path, "w") as snippet_file: snippet_file.write(phrase + "\n")
def markdown(html): try: default = open(expand_path("~/.nvm/alias/default")).read().strip() except: return "nvm is not set up for marked on this machine" node_root = os.path.join("~/.nvm/versions/node/", default) node_root = expand_path(node_root) args = [ os.path.join(node_root, "bin/marked"), ] popen = subprocess.Popen( args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE ) (html, stderr) = popen.communicate(html) if stderr: sys.stderr.write("ERROR: %s" % stderr) return print("copying HTML onto the clipboard\n" + html) return html
def noscreenshots(): desktop = expand_path("~/Desktop") trash = expand_path("~/.Trash") for name in glob.glob(os.path.join(desktop, "Screen Shot*.png")): print name os.rename(name, os.path.join(trash, os.path.basename(name)))
def fantastical(*words): run([expand_path("~/bin/fantastical.sh")] + list(words))
def notes(): run( ["/usr/local/Caskroom/google-chrome/latest/Google Chrome.app/Contents/MacOS/Google Chrome", "--incognito", expand_path("~/projects/dotfiles/notes.html")] )
def append_entry(journal_path, message): outFile = open(expand_path(journal_path), "a") outFile.write("\n\n# %s\n- %s\n" % (timestamp(), message)) outFile.close() commander.mac.pbcopy(message)
def double_quote_mode(): try: os.unlink(expand_path("~/.single_quotes")) except (OSError): # ignore, file didn't exist pass
def single_quote_mode(): with open(expand_path("~/.single_quotes"), "w") as out: out.write("")
def editor(path): path = expand_path(path) run(["/usr/local/bin/atom", path])
from commander import engine from commander.helpers import expand_path from commander.helpers import noclear from commander.helpers import run from commander.helpers import split import commander conf_path = join( os.path.dirname(os.path.realpath(__file__)), "mycommands-conf.json") with open(conf_path) as confFile: conf = json.load(confFile) engine.add_reloader(conf_path, commander.full_reload) ACTIVE_PROJECT = expand_path("~/.active_project") projects = { "fp": "FootprintID", "gl": "GorillaLogic", "sp": "Small Planet" } def project_specific_browser(command): if "app" in command: return arg = command.get("args", [""])[0] if not arg.startswith("http"): return with open(ACTIVE_PROJECT) as ap_file: project = ap_file.read().lower().strip()