[问题]如何设置使page/Up(Down)调出使用过的历史命令?(已经解决)

sh/bash/dash/ksh/zsh等Shell脚本
回复
头像
yechf
帖子: 305
注册时间: 2006-04-27 12:18
来自: 浙江德清武康

[问题]如何设置使page/Up(Down)调出使用过的历史命令?(已经解决)

#1

帖子 yechf » 2007-06-27 6:56

比如,我用mandriva,在shell下输人urpmi,然后按几下page up,就会出来以前输人过的urpmi开头的命令,象urpmi --auto --auto-select一类的命令,很方便。
ubuntu如何实现?
上次由 yechf 在 2007-06-28 17:08,总共编辑 3 次。
头像
laborer
帖子: 1016
注册时间: 2005-10-25 11:15
联系:

#2

帖子 laborer » 2007-06-27 7:09

可以用ctrl-r搜索以前用过的指令。
hreiser@oakland:~$ killall -9 wife
police@oakland:~$ sudo find / -user hreiser
court@oakland:~$ sudo mv /home/hreiser /jail/
court@oakland:~$ sudo usermod -d /jail/hreiser -s "/usr/sbin/chroot /jail/" hreiser
头像
yechf
帖子: 305
注册时间: 2006-04-27 12:18
来自: 浙江德清武康

#3

帖子 yechf » 2007-06-27 23:48

用ctrl+r不能实现我想要的功能。
头像
iblicf
帖子: 3766
注册时间: 2007-01-15 17:15

#4

帖子 iblicf » 2007-06-28 0:23

直接用 ↑ ↓翻 ,
或者 !u 回车
或者 urpmi !$ ("!$"是重复上一个命令的参数)
头像
yechf
帖子: 305
注册时间: 2006-04-27 12:18
来自: 浙江德清武康

#5

帖子 yechf » 2007-06-28 7:55

楼上的也不行,而且麻烦。
不过,谢谢。
ltkun
帖子: 1340
注册时间: 2006-01-10 19:09

#6

帖子 ltkun » 2007-06-28 8:18

/etc/inputrc 自己去找两行把注释去掉
头像
yechf
帖子: 305
注册时间: 2006-04-27 12:18
来自: 浙江德清武康

#7

帖子 yechf » 2007-06-28 17:03

谢谢楼上。
我cp了mandriva的/etc/inputrc就搞好了。



以下是mandriva的:
## Mandriva Linux Configuration
# (c) Mandriva 1999-2005
# Chmouel Boudjnah, Pablo Saratxaga <pablo@mandriva.com>
# $Id: inputrc,v 1.9 2005/12/07 06:56:46 flepied Exp $


# Show all if ambigious.
set show-all-if-ambiguous on

# 8Bits supports.
set meta-flag on
set convert-meta off
set input-meta on
set output-meta on

# bash completions does not use more
set page-completions off

# definition of keys in vi mode if vi mode is set at login result
# in totally messed up command line... so it safer to activate it
# only for emacs mode; until the bug is fixed (in libreadline?)
$if mode=emacs

# Keyboard configuration
"[2~": yank # Insert
"[3~":delete-char # Suppr

"[1~": beginning-of-line # Home
"[4~": end-of-line # End

# typing the beginning of a previous command then
# PgUp/PgDw cycles trough history only for matching entries
"[5~": history-search-backward # Previous
"[6~": history-search-forward # Next

# those two are for rxvt
"\e[7~":beginning-of-line
"\e[8~":end-of-line

# on some xterm
"\e[H": beginning-of-line
"\e[F": end-of-line

# on nxterms
"\e[\C-@": beginning-of-line
"\e[e": end-of-line

$if term=xterm
#
# Application keypad and cursor of xterm
# with NumLock ON
#
# Operators
"\eOo": "/"
"\eOj": "*"
"\eOm": "-"
"\eOk": "+"
"\eOl": "+"
"\eOM": accept-line

# Colon and dot
# "\eOl": ","
"\eOn": "."

# Numbers
"\eOp": "0"
"\eOq": "1"
"\eOr": "2"
"\eOs": "3"
"\eOt": "4"
"\eOu": "5"
"\eOv": "6"
"\eOw": "7"
"\eOx": "8"
"\eOy": "9"
$endif

#
# Application keypad and cursor of xterm
#
"\eOD": backward-char
"\eOC": forward-char
"\eOA": previous-history
"\eOB": next-history
"\eOE": re-read-init-file

# emacs mode
$endif
回复