http://teohm.com/blog/shortcuts-to-move-faster-in-bash-command-line/

Shortcuts to move faster in Bash command line

Jan 4, 2012

Nowadays, I spend more time in Bash shell, typing longer commands. One of my new year resolutions for this year is to stop using left/right arrow keys to move around in the command line. I learned a few shortcuts a while ago.

Last night, I spent some time to read about “Command Line Editing” in the bash manual. The bash manual is a well-written piece of documentation. I think I should read it more often.

Well, here’s the new shortcuts I learned:

Basic moves

  • Move back one character. Ctrl + b
  • Move forward one character. Ctrl + f
  • Delete current character. Ctrl + d
  • Delete previous character. Backspace
  • Undo. Ctrl + -

Moving faster

  • Move to the start of line. Ctrl + a
  • Move to the end of line. Ctrl + e
  • Move forward a word. Meta + f (a word contains alphabets and digits, no symbols)
  • Move backward a word. Meta + b
  • Clear the screen. Ctrl + l

What is Meta? Meta is your Alt key, normally. For Mac OSX user, you need to enable it yourself. Open Terminal > Preferences > Settings > Keyboard, and enable Use option as meta keyMeta key, by convention, is used for operations on word.

Cut and paste (‘Kill and yank’ for old schoolers)

  • Cut from cursor to the end of line. Ctrl + k
  • Cut from cursor to the end of word. Meta + d
  • Cut from cursor to the start of word. Meta + Backspace
  • Cut from cursor to previous whitespace. Ctrl + w
  • Paste the last cut text. Ctrl + y
  • Loop through and paste previously cut text. Meta + y (use it after Ctrl + y)
  • Loop through and paste the last argument of previous commands. Meta + .

Search the command history

  • Search as you type. Ctrl + r and type the search term; Repeat Ctrl + r to loop through results.
  • Search the last remembered search term. Ctrl + r twice.
  • End the search at current history entry. Ctrl + j
  • Cancel the search and restore original line. Ctrl + g

Need more?

bash - move faster的更多相关文章

  1. [Bash] Move and Copy Files and Folders with Bash

    In this lesson we’ll learn how to move and rename files (mv) and copy (cp) them. Move index.html to ...

  2. shell浅谈之十函数

    转自:http://blog.csdn.net/taiyang1987912/article/details/39583179 一.简介 Linux Shell编 程中也会使用到函数,函数可以把大的命 ...

  3. iOS 学习 - 10下载(3) NSURLSession 音乐 篇

    使用 NSURLSession 下载,需要注意的是文件下载文件之后会自动保存到一个临时目录,需要开发人员自己将此文件重新放到其他指定的目录中 // // ViewController.m // Web ...

  4. Deep Learning in a Nutshell: History and Training

    Deep Learning in a Nutshell: History and Training This series of blog posts aims to provide an intui ...

  5. September 26th 2016 Week 40th Monday

    The land didn't move, but moved. The sea wasn't still, yet was still. 大地止而亦行,大海动而亦静. Still waters ru ...

  6. 【HDU 3810】 Magina (01背包,优先队列优化,并查集)

    Magina Problem Description Magina, also known as Anti-Mage, is a very cool hero in DotA (Defense of ...

  7. PhoenixFD插件流体模拟——UI布局【Gird】详解

    流体网格 本文主要讲解Grid折叠栏中的内容 主要内容 Overview 综述 Parameters 参数 General 普通参数 Example: Scene Scale Example: Gri ...

  8. Robot Operating System (ROS)学习笔记3---键盘控制

    搭建环境:XMWare  Ubuntu14.04  ROS(indigo) 转载自古月居  转载连接:http://www.guyuehome.com/253 一.创建控制包 catkin_creat ...

  9. Five reasons phosphorene may be a new wonder material

    A material that you may never have heard of could be paving the way for a new electronic revolution. ...

随机推荐

  1. ELKstack 中文指南

    https://www.elastic.co/downloads ELKstack 中文指南 .net Elasticsearch 学习入门笔记   一. es安装相关1.elasticsearch安 ...

  2. 一句SQL按照某个字段数值拆分出对应的数据条数,借助数据库常量表【master..spt_values】实现

    简介:master..spt_values,数据行拆分简单小技巧 SELECT ProjGUID , CostGUID , SUM(FtAmount) AS FtAmount , BeginMonth ...

  3. 1.字符设备驱动------Linux中断处理体系结构

    一.中断处理体系结构的初始化 Linux内核将所有的中断统一编号,使用一个irq_desc结构数组来描述这些中断;每个数组项对应一个中断,也可能是一组中断,它们共用相同的中断号,里面记录了中断的名称. ...

  4. PYTHON学习第五天课后总结:

    今日重点: 数字类型 字符串类型 列表类型 元组类型 1,数字类型    数字类型为不可变类型   也只能将纯数字类型的字符串转换成int包括: 整型: int()     int() 为内置函数,可 ...

  5. android 闹钟提醒并且在锁屏下弹出Dialog对话框并播放铃声和震动

    android 闹钟提醒并且在锁屏下弹出Dialog对话框并播放铃声和震动            1.先简单设置一个闹钟提醒事件: //设置闹钟 mSetting.setOnClickListener ...

  6. 1.3 Quick Start中 Step 1: Download the code官网剖析(博主推荐)

    不多说,直接上干货! 一切来源于官网 http://kafka.apache.org/documentation/ 不要局限于,这个版本,我只是以最新的版本,来做个引子,让大家对官网的各个kafka版 ...

  7. html 代码

    1.结构性定义 文件类型 <HTML></HTML> (放在档案的开头与结尾) 文件主题 <TITLE></TITLE> (必须放在「文头」区块内) 文 ...

  8. Altium Designer中距离的测量

    Ctrl+M 清除测量标签:点击右下角的清除按键

  9. js里的表格数组某个key去重

    如Elemgnt的table绑定的数据要某个key是唯一的 var myarry = [ {name: 'liuyang',age :13}, {name:'jike',age:15}, {name: ...

  10. PythonNET网络编程1

    # PythonNET 网络编程 ISO(国际标准化组织) 制定了 OSI(Open System Interconnectio),意为开放式系统互联.国际标准化组织(ISO)制定了OSI模型,该模型 ...