Eduardo Bellido Bellido
Systems Engineer at Adevinta Spain. FLOSS lover, and passionate about Agile and DevOps. Podcasting in https://www.entredevyops.es
by
Pick a powerful terminal emulator and master it's usage
GNU/Linux: Tilix, Terminator, Konsole
Mac OS X: iterm2 obviously...
Windows: I've no idea... recommendations?
If you prefer not to be tied to a GUI app, use tmux, no worries about the terminal emulator, the cool stuff will be done by tmux
The shell is the essence when working in the terminal, so it's important to configure it properly to boost your productivity
The three are powerful and pretty configurable, just read the docs, compare it and pick one, the one that suits best to you
When bash starts as login shell:
~/.bash_profile
When bash starts interactively:
~/.bashrc
GNU Readline config file (not only for Bash):
~/.inputrc
Put (almost) all your configuration in .bashrc
Then, in .bash_profile, put:
if [[ -f ~/.bashrc ]]; then
source ~/.bashrc
fi
autocd → enter directories without typing cd
cdspell → correct minor spelling errors in directory names
globstar → enable the pattern '**'
histappend → history list is appended rather than overwritten
Enable it adding the corresponding entry to your .bashrc:
shopt -s <option name>
Some variables to control the history behavior:
HISTCONTROL='ignorespace:ignoredups:erasedups'
HISTSIZE=1000
HISTFILESIZE=3000
HISTTIMEFORMAT='[%F %T] '
"\e[A": history-search-backward
"\e[B": history-search-forward
"\C-p": history-search-backward
"\C-n": history-search-forward
Filtered history search, add this lines to .inputrc file:
$ history
1 cd /tmp
2 wget https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.0.4.tar.xz
3 tar xvJf linux-4.0.4.tar.xz
4 cd linux-4.0.4
5 make oldconfig
6 make -j 4
7 make modules_install
8 make install
# append history lines from current session to the history file
$ history -a
# update the current history list
$ history -r
!n → Refer to command line n
!! → Refer to the previous command (tip: sudo !!)
!string → Refer to the most recent command preceding the current position in the history list starting with string
^ string1 ^ string2 ^ → Quick substitution. Repeat the last command, replacing string1 with string2
!$ → the previous command last argument
!^ → the previous command first argument
!* → the previous command all arguments
C-p → Move 'back' through the history list, fetching the previous command
C-n → Move 'forward' through the history list, fetching the next command
C-r → Search backward starting at the current line and moving 'up' through the history as necessary
C-s → Search forward starting at the current line and moving 'down' through the the history as necessary (try "stty -ixon" if doesn't work)
C-g → Escape from history searching mode
Expands the history commands
$if Bash
Space: magic-space
$endif
Enable it adding these lines to your .inputrc file:
Bonus:
C-M-e → expand the line as the shell does
C-a → Move to the start of the current line
C-e → Move to the end of the line
C-f → Move forward a character
C-b → Move back a character
M-f → Move forward to the end of the next word
M-b → Move back to the start of the current or previous word
M-Del → Delete the Word before the cursor
M-d → Delete the Word after the cursor
C-d → Delete character under the cursor
C-h → Delete character before the cursor (Backspace)
C-w → Cut the Word before the cursor to the clipboard
C-k → Cut the Line after the cursor to the clipboard
C-u → Cut/delete the Line before the cursor to the clipboard
C-y → Paste the last thing to be cut (yank)
C-_ → Undo
C-x C-e → Edit the current input using $VISUAL or $EDITOR
Create aliases for common command usages, with the arguments you usually use the most
If an alias is not enough, simplify complex tasks writing shell functions, there's no need to look for new commands or creating new ones
A lot of commands have a completion script, that can help us a lot doing suggestions when hitting TAB, like an IDE when programming
You need to "source" the completion scripts in your Bash config files (p.e. .bashrc)
Can be a bit tricky depending on your platform and environment
Bash supports a plenty of options to show information about your environment, hostname, cwd, etc.
But luckily exists PROMPT_COMMAND, to put literally almost everything in your prompt
Collections of scripts, aliases, and completions for Bash, also provides some useful improvements for the prompt.
Prompt improvements, written in python, a bit slow. Also supports more applications, Vim, tmux...
Prompt improvements, supports plugins, currently only have a few.
Improved git prompt, very very verbose.
grep tee cut find nl xargs watch tail sort diff uniq wc sed cat
curl tr comm head
Official project description:
fzf is a general-purpose command-line fuzzy finder.
It's an interactive Unix filter for command-line that can be used with any list; files, command history, processes, hostnames, bookmarks, git commits, etc.
$ sudo applause
By Eduardo Bellido Bellido
Boost your productivity mastering the usage of the terminal, the shell, and CLI applications.
Systems Engineer at Adevinta Spain. FLOSS lover, and passionate about Agile and DevOps. Podcasting in https://www.entredevyops.es