Infinite Loop / While True One-liner
while :; do thing; done
Highlight a term from a program output
cat file | ack --passthru "TERM"
Replace text in a file
sed -i s/[find]/[replace]/g file
File / Directory Searching
Syntax:
find [directory] <flags>
For each line do…
... | xargs -L1 -i{} echo Hello, {}!
Flags
-iname "filename"
- case insensitive search for “filename”-name "filename"
- case sensitive search for “filename”-iname "*.txt"
- case insensitive search for files/directories ending with “.txt”-type f
- filter files-type d
- filter directories-exec [cmd] \;
- perform a command on each file.{}
to reference the path-maxdepth [n]
- maximum number of directories to recurse
Git Usefuls
- Ignore CR/LF endings
git config --global core.autocrlf true
Ignore file mode permissions
git config –global core.filemode true
git lg
- alias for a pretty log summarygit config –global alias.lg=log –color –graph –pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' –abbrev-commit
Git backup loop - perfect for badly version-controlling files!
#!/bin/bash
cd "$(dirname "$0")"
while :
do
echo "Making backup at `date`"
git add . > /dev/null
git commit -m "Backup :: `date`" > /dev/null
sleep $((10 * 60)) # 10 min interval
done
Disable Python .pyc files from being created
export PYTHONDONTWRITEBYTECODE=1
Auto-start a service
systemctl enable SERVICE_NAME
systemctl disable SERVICE_NAME
2FA Authentication Setup
Software
exifclean
- remove EXIF data from a file/files in a directoryalias exifclean="exiftool -r -P -gps:all= -overwrite_original"
ncdu
- CLI disk usage analyseraskii
- TUI based drawing toolgitup
- Multi-Git repository updated- X2Go - Remote desktop / Linux application access
dog
- Improveddig
client (DNS)powerline
- Shell status promptzoxide
- Improvedcd
functionalitydelta
- git diff tooltty-share
- Terminal session sharing (over the web)
Drop-in Replacements
batcat
- Improvedcat
alias cat="batcat --tabs 2 --theme OneHalfDark"