Skip to content

Instantly share code, notes, and snippets.

@masutaka
Forked from yoshinari-nomura/.zaliases
Created September 27, 2011 16:14
Show Gist options
  • Save masutaka/1245509 to your computer and use it in GitHub Desktop.
Save masutaka/1245509 to your computer and use it in GitHub Desktop.
Small aliases to get along with Emacs buffer.
## Invoke the ``dired'' of current working directory in Emacs buffer.
function dired () {
emacsclient -e "(dired \"${1:a}\")"
}
## Chdir to the ``default-directory'' of currently opened in Emacs buffer.
function cde () {
EMACS_CWD=`emacsclient -e "
(expand-file-name
(with-current-buffer
(if (featurep 'elscreen)
(let* ((frame-confs (elscreen-get-frame-confs (selected-frame)))
(num (nth 1 (assoc 'screen-history frame-confs)))
(cur-window-conf (cadr (assoc num (assoc 'screen-property frame-confs))))
(marker (nth 2 cur-window-conf)))
(marker-buffer marker))
(nth 1
(assoc 'buffer-list
(nth 1 (nth 1 (current-frame-configuration))))))
default-directory))" | sed 's/^"\(.*\)"$/\1/'`
echo "chdir to $EMACS_CWD"
cd "$EMACS_CWD"
}
@masutaka
Copy link
Author

elscreen 対応版です。

@masutaka
Copy link
Author

masutaka commented Oct 7, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment