您的位置:首页 > 运维架构 > Shell

Emacs eshell的好处

2016-05-16 15:01 721 查看
一直在Linux下用shell,现在来谈谈eshell.
eshell是完全用elisp编写的shell,所以和shell不一样。shell会创建子进程比如bash. 因此eshell的语法和bash/sh并不完全一样。当然大多数都差不多。

eshell有几个优点
1. 在windows操作系统下,有了eshell,可以方便的运行Linux风格的命令,不需要再安装别的东西. 当然各个平台行为一致也是优点。
2. 支持重定向到其他buffer,用 >#<buffer ...> 格式
~ $ echo hello >#<buffer results>
~ $ ls >#<buffer *scratch*>
这样,会将hello输出到result buffer中,会将ls的结果输出到*scratch*buffer中。
3. grep的结果会包含链接,点击直接打开文件并跳转到结果表示的那一行。这个实在是太赞了。
4. eshell里面直接运行elisp, 相当方便
~ $ (+ 2 1)
3
5. 运行man命令
shell中
$ man grep
WARNING: terminal is not fully functional
- (press RETURN)
GREP(1) General Commands Manual GREP(1)

NAME
grep, egrep, fgrep - print lines matching a pattern

SYNOPSIS
grep [OPTIONS] PATTERN [FILE...]
grep [OPTIONS] [-e PATTERN | -f FILE] [FILE...]

DESCRIPTION
grep searches the named input FILEs for lines containing a match to the given PATTERN. If no files are specified, or if the file “-” is given, grep searches standard input. By default, grep
prints the matching lines.

In addition, the variant programs egrep and fgrep are the same as grep -E and grep -F, respectively. These variants are deprecated, but are provided for backward compatibility.

OPTIONS
Generic Program Information
--help Output a usage message and exit.

-V, --version
Output the version number of grep and exit.

Matcher Selection
不能显示全,

而在eshell中,直接打开一个buffer显示,效果和M-x man一样,但是更加快捷。

注意
eshell仍然是一个编辑器,eshell里的所有内容都可以作为文本复制,但是必须用C-n 和 C-p来上下移动光标,上下键无效。
实际上在eshell中,控制光标应该这样,以我的Dell XPS 13为例
Fn/Home 移动到行首
C-a 移动到$后的第一个字符
Fn/End 或者 C-e移动到行尾
C-b 后移一个字符
C-f 前移一个字符
C-n 下移一行
C-p 上移一行
M-< buffer开头
M-> buffer结尾
M-g g 跳转到某一行,输入数字指定行号
M-g Tab 跳转到当前行某一列,输入数字制定列号

eshell的文档 http://www.gnu.org/software/emacs/manual/html_mono/eshell.html
推荐使用eshell,放弃shell吧。因为这更emacs.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  emacs