Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.
10 2 | Coming from a FreeBSD world I wish to make the Linux terminal behave like FreeBSD one, especially the 9.1 version, basically when you type cd in the terminal and push the "up" arrow you can browse all the commands in the history starting with cd which makes you gain a lot time.I don't know how to enable this feature in Linux Debian or CentOS which force me to type the whole, could someone please help. | |||
add comment |
17 | Add to the following to ~/.inputrc :
Explanation ~/.inputrc is the configuration file for GNU readline. Many shells, including bash and tcsh use readline for command line editing. The two lines above will tell readline to invoke its history search functionality when the escape sequences for the up-arrow key (\e[A ) and down-arrow key (\e[B ) are encountered. | ||||||||
|
4 | What's happening is that FreeBSD and Linux use different shells by default. FreeBSD defaults totcsh, which had better interactive features than bash in the past (but bash has caught up) butmarkedly worse scripting features. The most straightforward way to get the environment you're used to would be to switch your shell to tcsh on Linux. Provided that tcsh is installed system-wide (if it isn't, ask your system administrator to install it), run chsh -s tcsh to change your default shell.Alternatively, you can set up bash to have this command you're used to. By default, the Up and Down arrows navigate among all the commands in the history, not just the ones that start with the prefix you've typed. To change this to the behavior you're used to, put the following lines in bash's initialization file, which is .bashrc in your home directory. Either run . ~/.bashrc or start a new shell to re-read the initialization file.
The escape sequences are what your terminal sends to the shell when you press an arrow key. Up may be \eOA (escape, O , A ) or \e[A depending on your terminal, and similarly for Down.By default, bash offers different key bindings to search the command history. You can press Ctrl+R, then enter some characters to search for a command containing this substring anywhere on the line. Press Ctrl+S to go forward instead of backward. The search is incremental (i.e. as-you-type); Alt+P and Alt+N give you a non-incremental search. Instead of bash and tcsh, you could switch to zsh, which has some neat features not found in other shells. Zsh has Ctrl+R and Ctrl+S by default just like bash. To get Up and Down like you had in tcsh, put the following lines in ~/.zshrc :
If you'd like to use the same shell everywhere, you can use bash or zsh on FreeBSD too, provided that the port is installed (again, ask your system administrator). | ||
add comment |
1 | tcsh is available for most Linux distributions. Try installing the tcsh package, then running chsh -s /bin/tcsh to make it your default shell. | ||||||||
|
1 | Other answers tackle it, but if you want more, take a look at https://github.com/zsh-users/zsh-history-substring-search Prezto (https://github.com/sorin-ionescu/prezto) is also full of zsh goodies. | ||||||||
|
Not the answer you're looking for? Browse other questions tagged bash shell zsh command-history tcsh or ask your own question.
asked | 6 months ago |
viewed | 485 times |
active |
Hot Network Questions
- Why do C arrays not keep track of their length?
- Is it true that corporations influence the conclusions of research studies or papers?
- Is the Thomas algorithm the fastest way to solve a symmetric diagonally dominate sparse tridiagonal linear system
- How do I add a circumflex?
- How to handle a colleague who hasn't pulled their weight
- newcommand with optional superscript
- Should teachers be entertainers?
- How to get my old company to stop asking for help
- Probability with a coin and a die
- Regular Expression almost perfect for a Numeric Value
- EXT3: If block size is 4K, why does ls -l show file sizes below that?
- Using tikz (calendar), how can I control node positions?
- My cat is gaining too much weight, how often should I be feeding her?
- Getting coders to do code review
- What are French equivalents to the Latin “id est”?
- "FIZZ BANG BUZZ!" 3,7,11 efficiency
- In Dark Souls 2, what does this white soapstone icon mean?
- Fate/Freeport as a first RPG?
- Clarification on 得 usage
- What to do when you accidentally land on a runway thats borderline long enough to land on?
- Why do SSD's have weird sizes?
- Glide polar vs L/D ratio
- Why do mathematicians sometimes assume famous conjectures in their research?
- Is 'guns don't kill people people kill people' a good argument?
bindkey -k (up|down) history-search-(back|for)ward
in my.tcshrc
as described here. Cool! – Garrett Albright Oct 17 '13 at 20:27