-
-
Save mrquincle/45c7a2ea21d61726c2c535f710224bde to your computer and use it in GitHub Desktop.
Help (shell)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Command line | |
Force argument: interface=${1:? "usage"} | |
Resize gnome-terminal: resize -s 50 140 | |
Find file with wildcard: find . -name 'test*' | |
Untar --extract --file: tar xf archive.x.y.z -C directory | |
Unzip to directory: unzip archive.zip -d directory | |
Zip directory: zip archive.zip -r directory | |
Inline sed: sed -i '/Term/s/^/#/' | |
Process substitution: meld <(xxd file1) <(xxd file2) <(xxd file3) | |
Make Android screenshot: adb shell screencap -p | dos2unix > screen.png | |
Restart unity panel: killall unity-panel-service | |
File exists? [ -e "$file" ] && echo "present" || echo "absent" | |
Var set? [ -n ${var+x} ] && echo "set" || echo "unset" | |
Var set and non-empty? [ -n "${var}" ] && echo "set and non-empty" || echo "unset or empty" | |
Var not set? [ -z ${var+x} ] && echo "unset" || echo "set" | |
Var not set or empty? [! -n "${var}" ] && echo "unset or empty" || echo "set and non-empty" | |
Var set only if not set var=${var:-default} | |
Var equal to value (sh) if [ "$var" = "value" ]; then | |
Extract path ${VAR%/*} | |
Extract file ${VAR##*/} | |
Extract file without ext ${VAR%%.*} | |
Extract file without one ext ${VAR%.*} | |
Extract extension (.gz) ${VAR##*.} | |
Extract extension (.tar.gz) ${VAR#*.} | |
Unix time to date: date --date='@1425908833.293774' | |
Time date time msec date '+%Y%m%d_%H%M%S_%3N' | |
Module param values: sudo grep '' /sys/module/i915/parameters/* | |
Prettify json: < file.json python -m json.tool > pretty.json | |
Prettify json: < file.json jq . | |
Get json field 'results': < file.json jq '.results' | |
Get json array: < file.json jq '.results[]' | |
Build json struct: < file.json jq '.results[] | {address: .address, city: .city}' | |
Select based on subfield < file.json jq '.[] | select(.field == "text")' | |
List gsettings values: gsettings range org.gnome.settings-daemon.plugins.power critical-battery-action | |
List gsettings keys: gsettings list-recursively org.gnome.settings-daemon.plugins.power | |
Deep rsync: rsync -avzul --copy-links src dest | |
Find .deb package: dpkg -S /some/file | |
Sed substitution sed 's/test=\(.*\)/test=\1/g' | |
Cat including filename tail -n +1 directory/* | |
Copy completions (zsh) compdef cmd1=cmd2 | |
Get column 2 and 3 csvtool col 2-3 input.csv | |
Sum col 12 cat input.csv | csvtool drop 1 - | csvtool col 12 - | paste -s -d+ - | bc | |
Find files & print full path find . -type f -name "*.mp4" -exec readlink -f {} \; | |
Find process using port sudo ss -lptn 'sport = :8200' | |
Find TCP ports in use ss -t -a | |
Open last screenshot gimp ~/pictures/*(.om[1]) | |
List packages on size dpkg-query -W -f='${Installed-Size;8}\t${Package}\t${status}\n' | grep -v 'deinstall' | cut -f1-2 | sort -n | |
Remove newlines \nmatch sed ':r;$!{N;br};s/\nmatch//g' | |
Clean up hcidump sudo hcidump -x -R -t | sed 's/ /\n/g' | awk 'BEGIN{RS="\n\n" ; ORS="";}{ print }' | |
Remove empty lines | grep . | |
Sum numbers per line | paste -s -d+ - | bc | |
Drop last line sed '$ d' | |
Drop last line head -n -1 | |
Sum values in column cat numbers.txt | jq -s 'add' | |
Get Google Drive pdf getpdf file.gddoc | |
Use ctags for C++ ctags --c++-kinds=+p --fields=+iaS --extra=+q --language-force=c++ -R . | |
Specify ctags .h and .c files find . \( -name "*.h" -or -name "*.c" \) -exec ctags {} + | |
git | |
Subtree push: git subtree push --prefix docs/html upstream gh-pages | |
Revert single file: git checkout -- src/file.cpp | |
Unstage single file: git reset src/file.cpp | |
Diff file: git diff HEAD^^..HEAD src/file.cpp | |
Get folder from branch: git checkout master; git checkout branch folder | |
over files | |
Find and grep find . -name "*.cpp" -exec grep ENCYR {} \; | |
Find and sed find . -name "*.cpp" -exec sed -i 's/ENCYR/ENCRY/g' {} \; | |
convert | |
Resize image: convert input_file -resize 100x100 output_file | |
Convert *.png -> *.jpg for f in *.png; convert $f -resize 375x667 "${f%.*}.jpg" | |
Convert to color for f in *.png; convert $f -fuzz 40% -fill "#007cc3" -opaque black ../blue/$f | |
Convert to particular size convert -define jpeg:extent=500kb input_file output_file | |
Convert transparent (order!) convert -background none img.svg img.png | |
Create movie ffmpeg -f image2 -r 6 -pattern_type glob -i "*.png" output.mp4 -pix_fmt yuv420p | |
Create gif ffmpeg -ss 0:50 -i input.mkv -t 30 -s 480x270 result.gif -hide_banner | |
Crop 50px from left and right convert ifile -shave 50x0+50+0 +repage ofile | |
Crop bottom 50px convert ifile -gravity South -chop 0x50 ofile | |
Crop 640x480 with offset convert ifile -crop 640x480+50+100 ofile | |
List DPI identify -format %x,%yn -units PixelsPerInch ifile | |
Crop circularly step 1 convert -size 200x200 xc:Black -fill White -draw 'circle 100 100 100 1' -alpha Copy mask.png | |
Crop circularly step 2 convert ifile -gravity Center mask.png -compose CopyOpacity -composite -trim ofile | |
Add color to both sides convert ifile -background '#003e52' -gravity center -extent 3200x1800 ofile | |
Reverse order pdf pdftk ifile cat end-1 output ofile | |
Merge odd and even pdf pdftk A=fileA B=fileB shuffle A B output ofile | |
View pdf zathura ifile | |
Revert colors of pdf zathura: Ctrl+r | |
vim | |
Change case ~ | |
Record macro, example qa~wq @a | |
Count words select block; g Ctrl+g | |
Replace word :%s/\<foo\>/bar/g | |
Toggle header-source file :FSHere | |
Toggle header-source file :tag header (Ctrl+t to go back) | |
Open file :find cs_Error.h | |
Go to class :tag ADC | |
Go to definition Ctrl+] | |
Go back Ctrl+T (or :pop) | |
Show all tags g] | |
From "x" to <x> s/"\([^"].*\)./<\1>/g | |
Remove trailing whitespace s/[ \t]*$//g | |
Sort and make unique :sort u | |
Enhance list s/.*/case &:\rreturn "&";/g | |
Show matched lines: g/match/ | |
Remove matched lines: g/match/d | |
Copy to system clipboard :'<,'>w !cb' | |
Add character ë or â Ctrl+K e: or Ctrl+K a^ | |
Html URL to markdown :%s/<a href="\(.*\)">\(.*\)<\/a>/[\2](\1)/ | |
Html h1 to markdown :%s/<h1>\(.*\)<\/h1>/# \1/g | |
Html h2 to markdown :%s/<h2>\(.*\)<\/h2>/## \1/g | |
Where is an option set? :verbose set tabstop? | |
How to remove ^M? :%s/<Ctrl-V><Ctrl-M>//g (so first type Ctrl-V for ^ sign) | |
Update vim plugins vim +PluginInstall +qall | |
Remove vim plugins vim +PluginClean +qall | |
gam | |
Update gam bash <(curl -s -S -L https://git.io/install-gam) -l | |
Remove spam filter gam update group [email protected] spam_moderation_level allow | |
Add user to group gam update group [email protected] add member user [email protected] | |
netrw (vim file explorer) | |
Create new file % | |
i3 | |
Exit/quit session Meta+Shift+e | |
Lock screen Meta+Alt+l | |
X | |
Disable power down /usr/share/X11/xkb/symbols/inet change POWR | |
zsh | |
Tail last file tail *(.om[1]) | |
tmuxp | |
Go to window on the left Ctrl+B <- | |
Increase width to the right Ctrl+B Ctrl+-> | |
css | |
Add padding padding top right bottom left [px] (clockwise starting with top) | |
nmcli | |
Turn on wifi nmcli r wifi on | |
List all wifi networks nmcli c | |
Scan for networks nmcli d wifi rescan | |
List wifi networks nmcli d wifi list | |
Connect with network nmcli d wifi connect 'Wifi network' [password] | |
Print label lpr -o landscape -o fit-to-page -P Zebra_Technologies_ZTC_GK420d file | |
hardware | |
Set brightness echo 70 | sudo tee /sys/class/backlight/intel_backlight/brightness |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment