Backspace 出现乱码
在 Linux 命令行下输入 stty erase^h 即可。
方向键出现乱码
SQL> ^[[A^[[B^[[D^[[C^[[B^[[D^[[A^H^H
此时,需要下载两个免费软件 readline 和 rlwrap(我下载的是 readline-6.1.tar.gz 和 rlwrap-0.30.tar.gz )。
下载完成后在 Linux 系统下解压、编译、安装。
例如安装 readline,在 Linux 命令行下输入:
# 解压安装包
tar -zxvf readline-6.1.tar.gz
# 进入解压后的目录下
cd readline-6.1
# 生成 makefile
./configure
# 编译代码
make
# 安装软件
make install
安装 rlwrap 方法同上。(注意:安装软件需要在超级管理员权限下)
安装完上述两个软件之后,为了以后便于使用 rlwrap ,在运行用户目录下的 .bashrc 下添加两条语句。
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'
最后,重新加载环境变量即可,在Linux命令行下输入:
. ./.bashrc
如果没有 .bashrc ,修改 .bash_profile 或者 .profile 文件,方法同上。
sqlplus 下方向键乱码解决,可以方便的敲命令啦!
PS:rlwrap—rlwrap is a readline wrapper, a small utility that uses the GNU readline library to allow the editing of keyboard input for any other command. It maintains a separate input history for each command, and can TAB-expand words using all previously seen words and/or a user-specified file.
readline 是一个强大的库,只要使用了它的程序,都可以用同一个配置文件配置,而且用同样的方法操作命令行,让你可以方便的编辑命令行。