Tuesday, June 4, 2013

emacs javasscript

(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))

(eval-after-load 'js2-mode '(progn
                              (require 'js-beautify)

                              (add-to-list 'load-path "~/.emacs.d/jquery-doc.el")
                              (require 'jquery-doc)
                              (require 'flymake-jshint)

                              (add-hook 'js2-mode-hook '(lambda ()
                                                          (flymake-mode 1)
                                                          (local-set-key "\M-t" 'js-beautify)
                                                          (define-key js2-mode-map [(shift f10)]  (lambda()(interactive)(jslint-thisfile)))))

                              (eval-after-load 'js2-mode
                                   (define-key js2-mode-map (kbd "TAB") (lambda()
                                                                          (let ((yas/fallback-behavior 'return-nil))
                                                                            (unless (yas/expand)
                                                                              (if (looking-back "^\s*")

                              ;; javascript lint 
                              (defun jslint-thisfile ()
                                (compile (format "jsl -process %s" (buffer-file-name))))

                              (require 'js-comint)
                              ;; Use node as our repl
                              (setq inferior-js-program-command "node")
                              (setq inferior-js-mode-hook
                                    (lambda ()
                                      ;; We like nice colors
                                      ;; Deal with some prompt nonsense
                                      (add-to-list 'comint-preoutput-filter-functions
                                                   (lambda (output)
                                                     (replace-regexp-in-string ".*1G\.\.\..*5G" "..."
                                                                               (replace-regexp-in-string ".*1G.*3G" ">" output))))))


(provide 'rgr-javascript)

Tuesday, March 12, 2013

Informative bash prompt

I hop between machines a lot at home. I want to know their IP address easily in addition to history count, user, and (if available) git branch in my .basrg
export PS1='($IP) [\!]\[\033[00;32m\]\u\[\033[01m\]@\[\033[00;36m\]\h\[\033[01m\]:\[\033[00;35m\]\w\[\033[00m\]\[\033[01;33m\]`git branch 2>/dev/null|cut -f2 -d\* -s`\[\033[00m\]\$ '