Command line tips that developers should know

Command line tips that developers should know

1. Alt + click in one step

We often have to enter very similar commands on the command line with only a little modification. If the position you want to modify is the beginning or the end, you can quickly locate it by using shortcut keys. But if the position to be modified is in the middle of a long command, it is annoying. Use Alt + left and right arrows to jump by a word and press it a lot, and then press a single character to pinpoint it.

Solution: Alt + mouse click, in one step!

2. pbcopy and pbpaste: connect the command line pipeline and the clipboard

echo 'the Hello world' | pbcopy

echo ` pbpaste `

pbcopy receives the standard output from the command line as the content of the clipboard.

pbpaste outputs the content in the cut version to standard output.

3. Other useful shortcut keys

Ctrl + A: Move the cursor to the beginning of the line

Ctrl + E: Move the cursor to the end of the line

Ctrl + U: delete all characters before the cursor position (excluding the character at the current position)

Ctrl + K: delete all characters after the cursor position (including the character at the current position)

Ctrl + W: delete a word before the cursor

Ctrl + R: Search for previously used commands based on input

4. dot files

What are dot files? In Unix-like systems, file names beginning with a dot (.) are not displayed by default, such as .bash_profile, these files are called dot files. They are generally configuration files of various tools, such as bash, vim, etc. For example, we can set various commonly used long commands in bash as short commands that are convenient for our own use through aliases.

There are many people sharing their dot files on Github, and a lot of are included here   . Saving your own dot files on git has these advantages: it is convenient to backup, restore and synchronize, learn from others, and share your own.

Note that you can't use other people's things casually, and the best that suits you is the best. Originally dot files are used for personalized settings.

5. say command

Purely for entertainment, the say command in the shell is used to read the following string parameters (only English is supported), such as say 'hello world'.

There are many similar shortcut keys and tools, and the functions supported by different shell and terminal programs are also different.

Author: Kai Korea. This series of articles is reorganized based on the content of Addy & Matt's series of videos  Totally Tooling Tips . It mainly introduces some tools and techniques that (front-end) developers like.

Unless otherwise stated, the content of this article is licensed under Creative Commons Attribution 3.0 , and the code examples are licensed under Apache 2.0 . For more details, please check our terms of service .