eshell在启动的时候打印无关信息

eshell在启动的时候把我在profile文件里设置的path和alias什么的全都打印了一遍,怎么能让eshell隐性地加载profile文件呢?

Welcome to the Emacs shell

/usr/local/lib/python3.6:/usr/local/lib/python3.6/site-packages:/System/Library/Frameworks/Python.framework/Versions/2.7:/Users/yuan/.cargo/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:~/bin:/Library/TeX/texbin:/usr/local/aria2/bin:/usr/local/MacGPG2/bin:/opt/X11/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Wireshark.app/Contents/MacOS:/Library/TeX/texbin/:/Users/yuan/.cargo/bin:/usr/local/opt/make/libexec/gnubin:/usr/local/lib/python3.6:/usr/local/lib/python3.6/site-packages:/System/Library/Frameworks/Python.framework/Versions/2.7:/Users/yuan/bin:/Users/yuan/bin
true
/usr/local/opt/make/libexec/gnubin:/usr/local/lib/python3.6:/usr/local/lib/python3.6/site-packages:/System/Library/Frameworks/Python.framework/Versions/2.7:/Users/yuan/.cargo/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:~/bin:/Library/TeX/texbin:/usr/local/aria2/bin:/usr/local/MacGPG2/bin:/opt/X11/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Wireshark.app/Contents/MacOS:/Library/TeX/texbin/:/Users/yuan/.cargo/bin:/usr/local/opt/make/libexec/gnubin:/usr/local/lib/python3.6:/usr/local/lib/python3.6/site-packages:/System/Library/Frameworks/Python.framework/Versions/2.7:/Users/yuan/bin:/Users/yuan/bin
/usr/local/opt/make/libexec/gnuman:/usr/share/man:/usr/local/share/man:/Library/TeX/Distributions/.DefaultTeX/Contents/Man:/usr/local/MacGPG2/share/man:/usr/local/aria2/share/doc/man:/opt/X11/share/man:/Applications/Wireshark.app/Contents/Resources/share/man:/usr/local/opt/make/libexec/gnuman
/Users/yuan/.cargo/bin:/usr/local/opt/make/libexec/gnubin:/usr/local/lib/python3.6:/usr/local/lib/python3.6/site-packages:/System/Library/Frameworks/Python.framework/Versions/2.7:/Users/yuan/.cargo/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:~/bin:/Library/TeX/texbin:/usr/local/aria2/bin:/usr/local/MacGPG2/bin:/opt/X11/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Wireshark.app/Contents/MacOS:/Library/TeX/texbin/:/Users/yuan/.cargo/bin:/usr/local/opt/make/libexec/gnubin:/usr/local/lib/python3.6:/usr/local/lib/python3.6/site-packages:/System/Library/Frameworks/Python.framework/Versions/2.7:/Users/yuan/bin:/Users/yuan/bin
true
/Library/TeX/texbin/:/Users/yuan/.cargo/bin:/usr/local/opt/make/libexec/gnubin:/usr/local/lib/python3.6:/usr/local/lib/python3.6/site-packages:/System/Library/Frameworks/Python.framework/Versions/2.7:/Users/yuan/.cargo/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:~/bin:/Library/TeX/texbin:/usr/local/aria2/bin:/usr/local/MacGPG2/bin:/opt/X11/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Wireshark.app/Contents/MacOS:/Library/TeX/texbin/:/Users/yuan/.cargo/bin:/usr/local/opt/make/libexec/gnubin:/usr/local/lib/python3.6:/usr/local/lib/python3.6/site-packages:/System/Library/Frameworks/Python.framework/Versions/2.7:/Users/yuan/bin:/Users/yuan/bin
cat
ssh
emacsclient
emacsclient
en_US.UTF-8
en_US.UTF-8
┌─[yuan@missSilver]──[15:57]──[~]
└─> λ 

如何做到的?Eshell 也没有启动文件这回事。

. .profile

Or

source .profile

用这个可以做到。对应 eshell-source-file。但我没发现用这个如何导致文件内容打印出来。

实质是把文件内容当作 eshell 命令执行,但基本的 bash 风格命令还是兼容的,

噢,Eshell Script = 一些 Shell 语法 + Emacs Lisp

我从Mastering Emacs里看的。

Startup Scripts

Like most shells, Eshell supports both login and profile/rc shell scripts. The full filepaths for both are stored in the variables eshell-login-script and eshell-rc-script , but by default the files login and profile are stored in ~/.eshell/ .

It bears mention that the comment syntax is # .

我在我的eshell-directory-name下放了一个profile文件,eshell-rc-script好像是自动帮我设置了。

┌─[yuan@missSilver]──[21:37]──[/Users/yuan/.emacs.d/star/utility/eshell]
└─>:master* λ tree
.
├── alias
├── config.el
├── history
├── lastdir
├── package.el
└── profile

P.S. 抱歉回复这么慢,有别的事

明白 profile 怎么回事了,但是 Eshell 只是执行这个文件里的命令。你应该说明下你的 profile 的内容,最好用一个最小化的例子说明问题,而不仅仅把你遇到的问题原封不动地贴出来。

我基本是把所有zshrc里的东西port过来。

### ENV

setenv PATH "/usr/local/lib/python3.6:/usr/local/lib/python3.6/site-packages:/System/Library/Frameworks/Python.framework/Versions/2.7:$PATH:/Users/yuan/bin"


# syntax highlighting for cheat
setenv CHEATCOLORS true

# If you need to use these commands with their normal names, you
# can add a "gnubin" directory to your PATH from your bashrc like:
setenv PATH "/usr/local/opt/make/libexec/gnubin:$PATH"

# Additionally, you can access their man pages with normal names if you add
# the "gnuman" directory to your MANPATH from your bashrc as well:
setenv MANPATH "/usr/local/opt/make/libexec/gnuman:$MANPATH"

# rust
setenv PATH "$HOME/.cargo/bin:$PATH"

# pipenv shell now create .venv under project dir
setenv PIPENV_VENV_IN_PROJECT true

# tex support
setenv PATH "/Library/TeX/texbin/:$PATH"

# just print everthing and use Emacs as pager
setenv PAGER cat

# /ssh:/10.52.224.67:blah
# to: /10.52.224.67:blah
setq tramp-default-method "ssh"

### RC

# default editor
setenv VISUAL emacsclient
setenv EDITOR $VISUAL


# fix python error about locale
setenv LC_ALL en_US.UTF-8
setenv LANG en_US.UTF-8

setenv 的返回值是所设置的值,Eshell 会打印返回值,你可以改用 eshell/export,它的返回值总是 nil,Eshell 什么都不会打印。

setenv EDITOR vim
export EDITOR=vim

至于 eshell/setq,它的返回值也不是 nil

我不知道能不能抑制 Eshell 命令的输出。

1 个赞

感谢,我把setenv换成export,把setq移到别的地方就解决了。