74
Advanced Terminal Tips and Tricks
(www.bitsand.cloud)
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Follow the wormhole through a path of communities !webdev@programming.dev
My favorite tips are:
You can filter the output of a command. Most commands return parameters like
(output, error)
so you can filter them by number like1>/dev/null
will filter the output and only show the errors, and2>/dev/null
will filter the errors and only show the output. Also if you want a command to run silently but it doesn't have it's own built-in quiet mode you can add&>/dev/null
which will filter everything.Bash (and other shell's I assume) can be fully customized. In addition to the .bashrc file in your home directory, there are also a few common files that bash will look for like
.bash_aliases, .bash_commands, .bash_profile
or you can create your own and just add to the end of the .bashrc file./YOUR_CUSTOM_BASH_FILE_NAME
Inside that file you can add any custom commands you want to run for every bash shell like aliases and what not.
I personally often use a simple update command like so
alias up='sudo apt update -y && sudo apt upgrade -y && sudo apt autoremove -y'
which just makes running updates, upgrades, and clean-up so much easier. Just typeup
and enter your password. I have previously added in things like&>/dev/null
to quiet the commands andecho Fetching updates...
to make some commands quieter but still give some simple feedback.There's also the basics of moving around a terminal command as others have pointed out. The easiest and the one I use the most is if you hold CTRL+LEFT_ARROW the cursor will move entire words instead of one character at a time. Very helpful if you need to change something in the middle of a command.