mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-12-27 15:30:15 +08:00
New function efile
This commit is contained in:
parent
6f1929f822
commit
574de93efb
@ -24,14 +24,22 @@ if "$ZSH/tools/require_tool.sh" emacs 23 2>/dev/null ; then
|
|||||||
alias emasc=emacs
|
alias emasc=emacs
|
||||||
alias emcas=emacs
|
alias emcas=emacs
|
||||||
|
|
||||||
# jump to the directory of the current buffer
|
# Write to standard output the path to the file
|
||||||
|
# opened in the current buffer.
|
||||||
|
function efile {
|
||||||
|
local cmd="(buffer-file-name (window-buffer))"
|
||||||
|
$EDITOR --eval "$cmd" | tr -d \"
|
||||||
|
}
|
||||||
|
|
||||||
|
# display the directory of the file
|
||||||
|
# opened in the the current buffer
|
||||||
function ecd {
|
function ecd {
|
||||||
local cmd="(let ((buf-name (buffer-file-name (window-buffer))))
|
local cmd="(let ((buf-name (buffer-file-name (window-buffer))))
|
||||||
(if buf-name (file-name-directory buf-name)))"
|
(if buf-name (file-name-directory buf-name)))"
|
||||||
|
|
||||||
local dir=`$EDITOR --eval "$cmd" | tr -d \"`
|
local dir=`$EDITOR --eval "$cmd" | tr -d \"`
|
||||||
if [ -n "$dir" ] ;then
|
if [ -n "$dir" ] ;then
|
||||||
cd "$dir"
|
echo "$dir"
|
||||||
else
|
else
|
||||||
echo "can not deduce current buffer filename." >/dev/stderr
|
echo "can not deduce current buffer filename." >/dev/stderr
|
||||||
return 1
|
return 1
|
||||||
@ -39,7 +47,6 @@ if "$ZSH/tools/require_tool.sh" emacs 23 2>/dev/null ; then
|
|||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
## Local Variables:
|
## Local Variables:
|
||||||
## mode: sh
|
## mode: sh
|
||||||
## End:
|
## End:
|
||||||
|
Loading…
Reference in New Issue
Block a user