简体   繁体   中英

.bash_profile function to open emacs

i want to open a file in emacs, regardless of whether or not it already exists.

function emacs() {
    touch $1
    open -a Emacs.app $1
}

it only opens the file if it already exists. if i try a file that doesn't exist, i get the error:

The file /Users/danfithian/Desktop/Code/Euler/problem18.cpp does not exist.

I'm probably missing something, but why not just use emacs $1 (or the equivalent emacsclient call)? Isn't that sufficient? Emacs will create a new-file buffer if the file does not yet exist.

See this other question on Stack overflow. The suggestion there is to call the application directly /Applications/Emacs.app/Contents/MacOS/Emacs "$1" rather than through open

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM