Remember the cls
command from the legendary cmd.exe?
In the Bash Shell, the clear command does that. Two characters difference might seem trivial, but it does work for me, you might find it helpful; I dual boot Windows and Ubuntu, so having consistent commands helps.
Obvious tip: match your Windows shortcuts to Ubuntu, or vice versa, where you can. (Some already work on both OSes by default.)
With the alias
command, you can set up an alternate name for an existing shell command.
alias alt-name=command-name
For the cls and clear command scenario:
alias cls=clear
Works well enough right? Except it doesn't persist, bummer. Using the alias command to alias an existing command (pun might be intended) only works for the current session, like the Window: sessionStorage property in JavaScript (I do Web stuff). To ensure permanence, in the home directory or just cd ./~
You'll find a .bashrc file, which should be hidden by default, press Ctrl H
to toggle the hidden state. Create a .bash_aliases, and simply add alias cls=clear
; works now, somewhat like the Window: localStorage property in JavaScript (again, I write code using Web APIs that might be supported in all browsers or not, darn UX, support for Developer curiosity all the way, aye! I hope the W3C don't ban me)
If you have an existing terminal session live during the alias command permanence thingy, simply restart the terminal or run source ~/.bash_aliases
By the way, .bash_aliases is imported by the .bashrc file., and you can just edit it directly. You might be able to do this on Windows with the git bash shell or WSL.
Get creative with alias, git checkout
can be git ch
.; cd Desktop/folder
to cd-fo
.
alias cd-fo='cd ~/Desktop/folder'
If you need more info on alias or you're 'curious', help alias
or just (un)alias - You might find something interesting; you can check out my aliases
PS: Your OS is your limit.
exit