Last active
August 29, 2015 14:07
-
-
Save ashikahmad/9c659d24b83c28bdeb6c to your computer and use it in GitHub Desktop.
Some awesome tips and resources for smartly using shell. This are collected from here and there on internet. Basically it is for my own future reference as I forgot all the times :p
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ------------[ Shortcuts ]-------------- | |
# tab => Complete argument | |
# ctrl+w => Delete last (w)ord | |
# ctrl+u => Delete whole line | |
# ctrl+k => Delete from cursor to end of line (kill) | |
# ctrl+a => Cursor back to start of line | |
# ctrl+l => C(l)ear Screen | |
# ctrl+r => Sea(r)ch for previous command | |
# --------------------------------------- | |
# Alias for previous command: !! | |
# For example re-input previous command with sudo: | |
sudo !! | |
# Last specific command: !command | |
# For example this will run the last `cat` command you used | |
!cat | |
# If you just want to see, not run.. | |
!cat:p | |
# ..then you sure you'll run it, you can go !! | |
!! | |
# Argument of last command: !$ | |
# For example: | |
mkdir some_dir | |
cd !$ | |
# Go back to previous directory with a dash '-' | |
cd - | |
# Fix/replace previous command: ^ | |
# Note: replaces only first instance found. | |
# For example, if mistyped `nano some_long...` as `nanp some_long...` in last command, can be fixed like this | |
^nanp^nano | |
# See all previous history with a command (or anything) | |
history | grep nano | |
# This will list all commands with ids like: | |
# 381 sudo nano /etc/NetworkManager/nm-system-settings.conf | |
# 387 sudo nano /etc/rc.conf | |
# Then you can run one of those by that id | |
!381 | |
# To keep a command out of history, put a space before command | |
nano some_important_file.txt | |
# -- Note the space before `nano` -- | |
# Expansion: {} , Use braces to expand almost similar arguments or so | |
# For example: to rename | |
mv /path/to/file.{txt,xml} | |
# .. or to backup | |
sudo cp /etc/rc.conf{,-old} | |
# .. or restore from backup | |
sudo mv /etc/rc.conf{-old,} | |
# .. or something else.. [Note: This command below will create 3 dir: myfolder1, myfolder2, myfolder3] | |
mkdir myfolder{1,2,3} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment