From HN Guidelines:<p>If the original title begins with a number or number + gratuitous adjective, we'd appreciate it if you'd crop it. E.g. translate "10 Ways To Do X" to "How To Do X," and "14 Amazing Ys" to "Ys." Exception: when the number is meaningful, e.g. "The 5 Platonic Solids."
Here is one that should reset your terminal after accidentally reading a binary file, in most cases. Some of these are different on linux vs. unix vs. mac. You could put these in a file in /etc/profile.d/ or in your ~/.bashrc<p><pre><code> alias fix='reset; stty sane; tput rs1; clear; echo -e "\033c"'
</code></pre>
List only directories:<p><pre><code> alias lsd='ls -h -b --color=auto -d */'
</code></pre>
List by size:<p><pre><code> alias lss='ls -Ao --sort=s'
</code></pre>
Hand dyslexia, or the alternate to installing "sl"<p><pre><code> alias sl=ls
alias xit=exit
alias moer="more"
alias mroe="more"
</code></pre>
Long PS<p><pre><code> alias p="ps -Hefcwww"
</code></pre>
Shorthand for disk and memory usage:<p><pre><code> alias f="df -Ph;free -m"
</code></pre>
Bash function to display colors:<p><pre><code> function colors()
{
for fgbg in 38 48 ; do
for color in {0..256} ; do
echo -en "\e[${fgbg};5;${color}m ${color}\t\e[0m"
if [ $((($color + 1) % 10)) == 0 ] ; then
echo
fi
done
echo
done
}
</code></pre>
Functions to do rot13 and rot47 to get around word filters<p><pre><code> function rot13() { if [ -r $1 ]; then cat $1 | tr '[N-ZA-Mn-za-m5-90-4]' '[A-Za-z0-9]'; else echo $* | tr '[N-ZA-Mn-za-m5-90-4]' '[A-Za-z0-9]'; fi }
function rot47() { if [ -r $1 ]; then cat $1 | tr '\!-~' 'P-~\!-O' ; else echo $* | tr '\!-~' 'P-~\!-O'; fi }
</code></pre>
A couple of memory stat functions<p><pre><code> function memfree() {
free|awk '/^Mem/ {printf "%4.1f",($2-$4-$6-$7)/$2*100}'
}
function memperuser() {
ps aux | awk 'NR != 1 {x[$1] += $4} END{ for(z in x) {print z, x[z]"%"}}'
}</code></pre>
These are pretty neat, but weirdly uninformed on some things
.<p>If you're using GNU tar the alias should just be "tar -xvf" since it can autodetect compression (though I'm not sure if that's suffix-based or file type). This also means you can append your own -j or whatever for different compression types if you need to do so manually.<p>Specifying "wget -c" does not mean you'll be able to resume if something goes wrong, it forces resumption from a partial file you already have on a subsequent invocation. The reason to specify it on the first invocation is just so that you can be lazy and reuse that command line.<p>The shasum command is from Perl on most (all?) platforms, sha256sum from GNU coreutils or equivalent may be needed if it's missing and may have higher performance.<p>Probably most importantly, ipconfig is OS and distro-specific. It was missing on the first linux systems I checked (Ubuntu and openSUSE). It's useful, but it's a bit like listing a launchctl alias without specifying it's largely macOS-specific.