在 Linux 命令行中使用 Ctrl + R 反向查找/搜索历史命令

在 Linux 命令行中使用 Ctrl + R 反向查找/搜索历史命令

反向查找/搜索历史命令 - 反向查找/搜索执行过的命令

1. reverse-search-history (Ctrl + R)

Search backward starting at the current line and moving ‘up’ through the history as necessary. This is an incremental search. This command sets the region to the matched text and activates the mark.
从当前行开始向后搜索,并根据需要在历史记录中向上移动。这是一个增量搜索。此命令将区域设置为匹配的文本并激活标记。

1. 按下 Ctrl + R 组合键,进入反向搜索状态。

(base) yongqiang@yongqiang:~$
(reverse-i-search)`':

2. 输入查找字符串 git,显示历史命令中的一条匹配命令。

为了提高查找效率,应该输入要查找命令中最特别的字符 (别的命令不包含的字符)。

(base) yongqiang@yongqiang:~$
(reverse-i-search)`git': git branch -a

3. 继续按下 Ctrl + R 组合键,可以继续向前搜索匹配命令。

多次按下 Ctrl + R 组合键,可以继续向前搜索匹配命令。

(base) yongqiang@yongqiang:~$
(reverse-i-search)`git': git diff

4. 按下 -> 键,退出搜索状态/交互模式。

(base) yongqiang@yongqiang:~$ git diff

References

[1] Yongqiang Cheng, https://yongqiang.blog.csdn.net/
[2] 8.4.2 Commands For Manipulating The History, https://www.gnu.org/software/bash/manual/html_node/Commands-For-History.html

1. 在前端增加右下角的询盘表单弹窗: 可以使用以下代码实现,在 WordPress 主题的 functions.php 文件中添加以下代码: ```php add_action('wp_footer', 'my_custom_popup'); function my_custom_popup() { ?> <div id="popup-wrapper"> <div id="popup-content"> <h2>询盘表单</h2> <form> <label for="name">姓名:</label> <input type="text" id="name" name="name"> <label for="email">电子邮件:</label> <input type="email" id="email" name="email"> <label for="message">信息:</label> <textarea id="message" name="message"></textarea> <button type="submit">提交</button> </form> </div> </div> <style> #popup-wrapper { position: fixed; bottom: 0; right: 0; width: 300px; height: 300px; background-color: #fff; box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.5); z-index: 9999; } #popup-content { padding: 20px; } </style> <?php } ``` 这段代码会在网站的底部右侧增加一个 300x300 的弹窗,内部包含一个表单。你可以根据需要更改弹窗的大小和表单的内容。 2. 在前端的右侧增加在线悬浮窗口: 可以使用以下代码实现,在 WordPress 主题的 functions.php 文件中添加以下代码: ```php add_action('wp_footer', 'my_custom_chat_widget'); function my_custom_chat_widget() { ?> <div id="chat-widget"> <a href="https://wa.me/8518588629881" target="_blank"> <img src="https://www.example.com/wp-content/uploads/whatsapp-icon.png" alt="WhatsApp Chat"> </a> </div> <style> #chat-widget { position: fixed; bottom: 20px; right: 20px; z-index: 9999; } </style> <?php } ``` 这段代码会在网站的底部右侧增加一个 WhatsApp 聊天的悬浮窗口。你需要将图片的 URL 替换为你自己的图片,也可以根据需要更改悬浮窗口的位置和样式。 3. 后台的排版: 如果你需要在后台增加一些统计数据,可以使用 WordPress 提供的 REST API 和图表插件实现。 首先需要安装一个图表插件,例如 WPForms Charts and Graphs。 然后在 functions.php 文件中添加以下代码: ```php add_action('wp_enqueue_scripts', 'my_custom_enqueue_scripts'); function my_custom_enqueue_scripts() { if (is_admin()) { wp_enqueue_script('my-custom-script', get_template_directory_uri() . '/js/my-custom-script.js', array('jquery'), '1.0', true); } } add_action('admin_menu', 'my_custom_admin_menu'); function my_custom_admin_menu() { add_menu_page('Dashboard', 'Dashboard', 'manage_options
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Yongqiang Cheng

梦想不是浮躁,而是沉淀和积累。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值