top | item 23882784

Instant access to your shell init files

35 points| todsacerdoti | 5 years ago |emacsredux.com

9 comments

order
[+] b1476|5 years ago|reply
I’m all for Emacs tips and tricks, but this just seems unnecessary. Using find-file (C-x C-f) along with tab completion to open your .bashrc or whatever is literally several key strokes. Does anyone really edit their shell config that often to warrant binding it to a key to shave off several milliseconds?
[+] dmortin|5 years ago|reply
Yeah, it's not really worth it.

Your home directory should be indexed anyway (along with other interesting directories), so you should be able to simply quickly switch to any file in the index, regardless if it's open or not, using your favorite solution for this (Helm, etc.)

This makes bookmarking files pretty pointless, since all your interesting files are instantly available anytime with completion regardless of the current directory.

[+] reedlaw|5 years ago|reply
I use key-chord to bind xc (both keys pressed at the same time) to my emacs config file:

    (key-chord-define-global "xc" (lambda () (interactive) (find-file "~/.emacs.d/reed.org")))
[+] PuercoPop|5 years ago|reply
Also if you want a menu of places to go Emacs has bookmarks for that.
[+] mturmon|5 years ago|reply
Yep. The problem I really want to solve is, go to the shell init file where $LESS or $MANPATH or whatever is defined.
[+] m463|5 years ago|reply
I put it on F2

  (defvar init-files-list nil)

  (defun my-rotate-list (l)
    "Return list L with the first element moved to the end"
    (nconc (cdr l) (list (car l))))

  (defun edit-init-files-el ()
    "cycle through init-files-list, visiting each file"
    (interactive)
    (find-file (car init-files-list))
    (setq init-files-list (my-rotate-list init-files-list))
    (delete-other-windows (selected-window)))


  ;; elsewhere
  (append-list 'init-files-list
               '("~/.emacs.d/init.el"
                 "~/.bashrc"))

  (global-set-key [f2]      'edit-init-files-el)  ;; cycles init.el -> .bashrc -> ...
this is actually simplified, I append different startup files depending on the system I'm using, and I have a keys.el file devoted specifically to my key definitions that I put in the init-files-list