问题描述
我们都知道如何使用<按Ctrl> -R
来扭转通过历史记录搜索,但你是否知道,您可以使用<按Ctrl&GT ; -S
转发搜索,如果你设置的stty停止,
?另外,你有没有尝试过运行绑定-p以查看所有快捷键的上市?有超过455在Mac OS X默认情况下。
We all know how to use <ctrl>-R
to reverse search through history, but did you know you can use <ctrl>-S
to forward search if you set stty stop ""
? Also, have you ever tried running bind -p to see all of your keyboard shortcuts listed? There are over 455 on Mac OS X by default.
什么是您最喜欢晦涩诡计,键盘快捷键或禁用了javascript配置使用bash?
What is your single most favorite obscure trick, keyboard shortcut or shopt configuration using bash?
推荐答案
在运行命令时,有时我会想运行带有previous那些参数的命令。要做到这一点,您可以使用此快捷方式:
When running commands, sometimes I'll want to run a command with the previous ones arguments. To do that, you can use this shortcut:
$ mkdir /tmp/new
$ cd !!:*
有时,代替使用find,我会打破出的单行循环,如果我需要的文件列表上运行了一堆命令。
Occasionally, in lieu of using find, I'll break-out a one-line loop if I need to run a bunch of commands on a list of files.
for file in *.wav; do lame "$file" "$(basename "$file" .wav).mp3" ; done;
在我的.bash_login文件配置命令行历史记录选项(或.bashrc)中是非常有用的。以下是我在我的MacBook Pro使用设置的干部。
Configuring the command-line history options in my .bash_login (or .bashrc) is really useful. The following is a cadre of settings that I use on my Macbook Pro.
设置下列使得你的历史的bash擦除重复命令:
Setting the following makes bash erase duplicate commands in your history:
export HISTCONTROL="erasedups:ignoreboth"
我也千斤顶我的历史规模高达pretty高了。为什么不?它似乎没有今天的微处理器慢下来的任何
I also jack my history size up pretty high too. Why not? It doesn't seem to slow anything down on today's microprocessors.
export HISTFILESIZE=500000
export HISTSIZE=100000
这是我做的另一件事就是忽略我的历史的一些命令。无需记住exit命令。
Another thing that I do is ignore some commands from my history. No need to remember the exit command.
export HISTIGNORE="&:[ ]*:exit"
您一定要设置histappend。否则,bash将覆盖你的历史,当你退出。
You definitely want to set histappend. Otherwise, bash overwrites your history when you exit.
shopt -s histappend
这是我使用的另一种选择是cmdhist。这可以让你多行命令历史记录保存为一个命令。
Another option that I use is cmdhist. This lets you save multi-line commands to the history as one command.
shopt -s cmdhist
最后,在Mac OS X(如果你不使用vi模式),你会想重置&LT;&CTRL GT; -S被滚动停止。从能够跨preT它作为向前搜索这prevents庆典。
Finally, on Mac OS X (if you're not using vi mode), you'll want to reset <CTRL>-S from being scroll stop. This prevents bash from being able to interpret it as forward search.
stty stop ""
这篇关于什么是使用bash您最喜欢的命令行诡计?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!