Shell
在登陆 SDF 之后,你会发现包括方向键在内,Ctrl+A,Ctrl+B 等快捷键,都变成了屏幕上 ^A^B^[[C 这样的“乱码”,而不是像平时在 Linux 或是 macOS 的 Bash 那样“正常工作”。但是在 Unix 中,Readline 可并不是标配。最早的 Unix Shell 是 Thompson shell,sh
。在 Linux 分发版(在此我特意不用常见但并不准确的“发行版”一词来指代英文 Distribution)中,sh
通常是 bash
的替身。实际上很多人在 Shenbang 中用 sh
,实际却用了 bash
语法——如果这是要在別的系统上用的脚本,会有人要吃苦头的。而在许多 BSD 分发版中,sh
被链接到 Korn Shell,ksh
。SDF 用的 sh
则是一个接近 Korn Shell 的 POSIX Shell。Korn Shell 等 BSD 分发版上的 Shell 默认是不开启 Readline 的。而且因为 Readline 是 GPL 协议的软件,BSD 的 Shell 大多用 Editline (libedit),一个 BSD 协议的 Readline 替代品。
说了这么多,可是和方向键不生效有什么关系吗?好好,如果你急着用你熟悉的快捷键,在 Shell 中运行:
$ set -o emacs
也有人想用
vi
风格的按键吧?
你也可以把 set -o emacs
写入 ~/.profile
,这样就不用每次都运行一遍了。或者干脆用 chsh
来选择你更熟悉的 Bash。在 SDF,chsh
是 maint
的一个別名,它会让你登陆到专用于更改配置的服务器上。
SDF 当前可用的 Shell 有:
/bin/sh /bin/csh /bin/ksh /usr/pkg/bin/pdksh # 和 /bin/ksh 无实际区别 /usr/pkg/bin/tcsh /usr/pkg/bin/ksh93 /usr/pkg/bin/osh /usr/pkg/bin/esh /usr/pkg/bin/bash /usr/pkg/bin/screen # 非 MetaARPA 成员不可选 /usr/local/bin/closed # 不可选 /usr/pkg/bin/zsh /usr/pkg/bin/mksh
如果想给別的不支持 Readline 的软件增加支持,可以用 rlwarp
。
如果要显示中文显示,在 ~/.profile
加上 export LANG=zh_CN.UTF-8
就可以了,如果不喜欢命令行的汉化,用 en_US.UTF-8
亦可。
编辑器
目前 SDF 可用的编辑器一览:
ed Ken Thompson's editor (original UNIX editor) ex An EXtended ed line editor (between ed & vi) vi Bill Joy's editor (VIsual editor) nvi new vi bvi Gerhard Buergmann's VI based binary hex editor vim A VI clone vilearn VI interactive tutorial emacs Richard Stallman's emacs clone uemacs MicroEMACS beav A slightly emacs like binary editor zile Sandro Sigala's emacs clone ce Chet Ramey's emacs clone jed John E Davis' emacs clone jove Jonathan Payne's emacs clone Joe Joe's own editor pico Mark Crispin's MM SEND editor (?) nano a pico clone hexedit Pascal Rigaux's binary hex editor
其中支持中文编辑的有: vim
,emacs
,joe
,nano
。
GNU
你可能会发现,在 NetBSD 上一些常用的命令不接受其 Linux 版本可用的一些参数。这是因为,多数 Linux 分发版用的 GNU 组件在类 Unix 的 POSIX 标准之上自行添加了 BSD 不具有扩展。如果你想要用 Linux 风格的命令行工具,GNU 的组件如 Coreutils(mv
,ls
等),Awk,Grep,Sed 等被安装为 gmv
,gwak
,ggrep
,gsed
,以此类推。