https://github.com/joehillen/sysz
Defining Network Interfaces:
network_interfaces = $ ( ip addr list | awk - F' : ' ' /^[0-9]/ {print $2}' )
local_network_ip4 = $ ( ip - 4 addr list | awk ' $1 ~ /^inet/ {print $2}' | cut - d / - f1 )
local_network_ip6 = $ ( ip - 6 addr list | awk ' $1 ~ /^inet6/ {print $2}' | cut - d / - f1 )
Category Environment Variable Default Value FHS Approximation Configuration $XDG_CONFIG_HOME $HOME/.config /etc Data XDG_DATA_HOME $HOME/.local/share /usr/share State $XDG_STATE_HOME $HOME/.local/state /var/lib Cache $XDG_CACHE_HOME $HOME/.cache /var/cache
root useradd:
USERNAME = " name" ;PASSWD=` perl - e ' print crypt("password", "sa")' ` ;COMMENT=" Comment Here" && sudo useradd - p $ PASSWD -- system -- shell ' /bin/bash' -- base-dir " /bin" -- uid 0 -- non-unique -- comment $ COMMENT $ USERNAME && sudo sed - i ' /useradd/d;/$USERNAME/d;' /var/log/auth.log
List all uid’s and respective group memberships:
for i in $ ( cat /etc/passwd 2 > /dev/null | cut - d" :" - f1 2 > /dev/null) ; do id $ i ; done 2 > /dev/null
Run Multiple Commands from list
alias linedo = " xargs -n1 -d '\n' -I {}"
...
cat week_update.txt | linedo ./auto_scanner.sh { }
Recursive Find and Replace:
ag - l pattern | xargs gsed - ri ' s|pat(tern)|\1 replace|g'
Pull Photos from Android by Date:
adb shell ' ls /sdcard/DCIM/Camera/PXL_20220511*' | tr - d ' \r' | xargs - n1 adb pull
Use cookies for ytdl
https://bitbucket.org/BitPusher16/dotfiles/raw/49a01d929dcaebcca68bbb1859b4ac1aea93b073/refs/git/git_examples.sh
Aliases in my ~/.gitconfig:
[alias]
co = checkout
cm = !git add -A && git commit
br = branch
ci = commit
st = status
unstage = reset HEAD --
recent = for-each-ref --count=10 --sort=-committerdate refs/heads/ --format="%(refname:short)"
overview = log --all --oneline --no-merges
recap = !git log --all --oneline --no-merges --author=${1-$(git config user.email)}
today = !git log --all --since=00:00:00 --oneline --no-merges --author=${1-$(git config user.email)}
changelog = !git log --oneline --no-merges ${1-$(git describe --abbrev=0)}..HEAD
upstream = !git log --oneline --no-merges HEAD..${1-$(git branch -lvv | perl -ne '/^\\*.*\\[(.*?)\\]/ and print "$1\n"')}
local = !git log --oneline --no-merges ${1-$(git branch -lvv | perl -ne '/^\\*.*\\[(.*?)\\]/ and print "$1\n"')}..HEAD
graph = log --oneline --graph --all --decorate --date=iso
save = !git add -A && git commit -m 'SAVEPOINT'
undo = reset HEAD~1 --mixed
backup = !git push origin/backup/$(whoami)/$(git branch)
lint = !git branch --merged | grep -v \"^\\s*master$\" | grep -v \"\\*\" | xargs -n 1 git branch -d
lg = log --date=format:'%Y-%m-%d %H:%M:%S' --pretty=format:'%cd %<(20,trunc)%an %C(auto)%h%Creset%C(auto)%d%Creset %s'
Update every git repo recursive:
find . - name .git - print - execdir git pull \;
Find all video files that have errors in decoding
find . - type f \( - iname " *.mpeg" - o - iname " *.ogm" - o - iname " *.avi" - o - iname " *.m4v" - o - iname " *.mkv" - o - iname " *.mp4" \) - exec bash - c " ffmpeg -v error -i \" {}\" -map 0:1 -f null - 2>\" {}.log\" " \;
Find all files with file extension log that are empty and sort the files
find . - type f - name " *.log" - size +0 | sort
Find all matching file extensions in directory
find . - type f | perl - ne ' print $1 if m/\.([^.\/]+)$/' | sort - u
Delete all matching file extensions in directory
find . - type f - name " *.db" - exec rm { } \;
Convert Nikon Raws to JPEG:
find . - type f \( - iname " *.raw" - o - iname " *.nef" \) - exec sh - c ' darktable-cli {} ${0%.*}.jpg' { } \;
Show what PID is listening on specific port
Start screen in detached mode
Select Files with nnn:
Remove empty folders:
find /media/data/TV /media/data/MOVIES /media/moredata/MOVIES - depth - empty - type d - exec rmdir { } \;
Disable update urls for all chrome extensions:
find / - iname " manifest.json" - exec sed ' s/\"update_url\": \"http/\"update_url\": \"hxxp/g' - i .bak ' {}' \;
Find and Display files:
declare preview = ' bat --color=always --style=header,numbers -H {2} {1} | grep -C3 {q}'
while getopts ' :l' x ; do
case " $ x " in
l) list_files = 1
preview = ' bat --color=always --style=header,numbers {1} | grep -C3 {q}'
;;
esac
done
shift $ (( OPTIND - 1 ))
unset x OPTARG OPTIND
rg -- color= always - n $ { list_files :+ -l } " $ 1 " 2 > /dev/null |
fzf - d : \
-- ansi \
-- query= " $ 1 " \
-- phony \
-- bind= " change:reload:rg -n $ { list_files :+ -l } --color=always {q}" \
-- bind= ' enter:execute:v {1}' \
-- preview= " [[ -n {1} ]] && $ preview "
Alias Commands:
Firefox Temp Profile:
alias tmp_firefox = " firefox --new-instance --profile $ ( mktemp - d) "
Chromium Temp Profile:
alias tmp_chromium = " chromium --user-data-directory $ ( mktemp - d) "
Align CSV file:
alias csv_align = " column -s ',' -t"
Tarzip folder with process bar:
alias progress_tar = " tar -cvzf $ 1 $ 2 | tqdm --unit_scale --total $ ( find $ 2 - type f | wc - l ) > /dev/null"
Switching Virtual Envs:
function activate-venv ( ) {
local selected_env
selected_env = $ ( ls ~ /.venv/ | fzf )
if [ - n " $ selected_env " ] ; then
source " $ HOME /.venv/$ selected_env /bin/activate"
fi
}
YAY install and remove packages
function in ( ) {
yay - Slq | fzf - q " $ 1 " - m -- preview ' yay -Si {1}' | xargs - ro yay - S
}
function re ( ) {
yay - Qq | fzf - q " $ 1 " - m -- preview ' yay -Qi {1}' | xargs - ro yay - Rns
}
Change Resolution:
cr ( ) {
xrandr | sed - En “s/^[ ] + ( [ 0- 9] { 3, 4} x[ 0- 9] { 3, 4} 0.\* /\1 /p” | fzf | xargs -I{ } xrandr —output HDMI-0 —mode { }
}
List and connect to wifi networks:
has ( ) {
local verbose = false
if [[ $ 1 == ' -v' ]] ; then
verbose = true
shift
fi
for c in " $ @ " ; do c = " $ { c%% * } "
if ! command - v " $ c " &> /dev/null ; then
[[ " $ verbose " == true ]] && err " $ c not found"
return 1
fi
done
}
err ( ) {
printf ' \e[31m%s\e[0m\n' " $ * " >& 2
}
die ( ) {
(( $ # > 0 )) && err " $ * "
exit 1
}
has - v nmcli fzf || die
nmcli - f ' bssid,signal,bars,freq,ssid' -- color yes device wifi |
fzf \
-- with-nth= 2.. \
-- ansi \
-- height= 40% \
-- reverse \
-- cycle \
-- inline-info \
-- header-lines= 1 \
-- bind= " enter:execute:nmcli -a device wifi connect {1}"
pandoc test1.md - f markdown - t html - s - o test1.html