find . -name "rc.conf" -exec rm '{}' \;
find . -empty -exec rmdir '{}' \;
find . -type f -exec clean '{}' \;
Use -g
or --glob
rg {pattern-in-file} -g '!{pattern-to-exclude-in-filename}'
Use -l
or --files-with-matches
rg -l {pattern-in-files}
grep -Eo '@[^ ?]+' home/todo.md | sort -u
7z u -p{password} -mhe target.7z files
gpg --gen-key
gpg --export --armor {email} > gpg-public-key.txt
gpg --import gpg-public-key.txt
gpg --encrypt --output encrypted.gpg --recipient {email} {file-to-encrypt}
gpg {file.sig} # find public key ID
gpg --recv-key {key-id} # import key
gpg {file.sig} # verify signature
git reset --soft HEAD\^
git checkout -f
or
git reset --HARD
git reset --hard origin/master
git show {branch/tag/commit}:{path/to/file/from/repo/root}
example:
git show master:dir1/dir2/file.txt
git reflog --all
git fsck --lost-found
git reset --merge
git filter-branch \
--index-filter 'git rm --cached --ignore-unmatch path/to/file' \
{from}..{to}
git branch -d {branch}
git push --delete origin {branch}
git tag -d {tag}
git push origin :refs/tags/{tag}
git clean -f (all untracked files)
git clean -f -n (dry run)
git clean -f -n {path} (dry run on files in path)
git rebase -i {tag/commit}
# mark the commits you want to change with "edit" (or "e")
# for each commit do:
git commit --amend --author="Author Name <[email protected]>"
git rebase --continue
git checkout -b {branch} origin/{branch}
git co --theirs path/to/file
git add path/to/file
git remote prune {remote}
git rebase -i --exec <build command> <first sha you want to test>~
-
Delete module from .gitmodules and stage it (
git add .gitmodules
) -
Delete the section from .git/config
-
Run
git rm --cached path/to/submodule rm -rf .git/modules/submodule
-
Commit the change
-
Delete the now untracked submodule files (
rm -rf path/to/submodule
).
git format-patch -1 {hash} git am < {file.patch}
convert --sample 50% input.png output.jpg
convert -colors 2 input.png output.png
convert file1.png file2.png output.pdf
convert -page {width}x{height} file1.png file2.png output.pdf
convert -density 200 input.pdf output.png
convert arrow-left.png -flop arrow-right.gif
convert arrow-up.png -flip arrow-down.gif
awk '{ print $2 }'
awk '{s+=$6} END { print s }'
awk '{ printf "%''d\n", $1 }'
awk "{ printf \"%'d\n\", $1 }"
name='file.ext'
echo ${name:r} # => outputs 'file'
fullpath='/path/to/file.ext'
echo ${fullpath:t} # => outputs 'file.ext'
name='file-bob.txt'
echo ${name:s/bob/joe} # => outputs 'file-joe.txt'
compinit
cat $filename | while read line; do echo $line; done
# to avoid the subshell (so you can access variables outside the loop) you
# can do this:
lines=()
while read line; do lines+=($line); done < $filename
for line in ${lines[@]}; do ...; done
sudo killall VDCAssistant
(see https://discussions.apple.com/thread/4158054?start=0&tstart=0)
dscacheutil -flushcache
kextstat
sudo kextunload -v -b {bundle-id}
e.g.
sudo kextunload -v -b com.FTDI.driver.FTDIUSBSerialDriver
osascript -e 'id of app "Finder"'
(e.g. for amethyst)
psql -h {host} -p {port} -U {username} {database}
\? - show help (all commands)
\l - show all databases
\d - show all tables and other objects
\dt - show all tables
\db - show all tablespaces
\d+ - describe table
\x {on|off} - turn extended display on/off
curl --cookie "cookie_name=cookie_value" http://...
curl -L http://...
gsutil acl ch -u AllUsers:R gs://bucket/file.txt
s3cmd setacl 's3://{bucket-name}/{path}/**/*' --acl-public --verbose
s3cmd ls 's3://{bucket-name}/{path}' -r
:w !sudo tee %
Columns: minute hour day-of-month month day-of-week command
Every 30 minutes:
*/30 * * * * the_command
Debugging native compilations:
- use "-x" to printout the build flags (e.g.
go get -x {package}
)
This is a link to Something
nix-channel --update
nix-env -u
nix-env -i {package}
nix-env -e {package}
nix-env -qaP '.*{name}.*'
nix-env -qa --description '.*{name}.*'
dpkg -l
dpkg -l '*qt*'
dpkg -L 'package-name'
sudo -s -u {user}
lsof -i -n -P
(use sudo to show processes by all users)
echo "hello" | cut -c 3- # will output "llo"
ctrl+c reset
ctrl+c stty sane
wc -l
cat file.xml | xmllint --format -
od -xcb {file}
/msg nickserv help
/msg nickserv register <password> <email-address>
bzr branch bzr+ssh://{username}@{hostname}/path/to/repo local_dir_to_create
tmux attach -d
tmux attach -d -t specific_session_name
lsb_release -a
# show only summary (e.g. "file1 differs"):
diff -rq dirA dirB
# show diff for each file:
diff -r dirA dirB
sudo update-alternatives --config x-terminal-emulator
xdg-mime query default x-scheme-handler/mailto
xdg-mime default google-chrome.desktop x-scheme-handler/mailto
dc - calculate total size of selected items
dd - cut
pp - paste
gn - new tab
gt - next tab
w - task view
zz - filter
.c - clear filter
! - :shell
@ - :shell %s (run on selected items)
dd - delete files
yy - yank files
p - paste yanked files
P - move yanked files
:copy & - copy in background
:move & - move in background
:jobs - show background jobs
cw - rename file(s)
cW - rename file(s) without extension
o - create directory [custom]
:trashes - list trash directories (one per partition)
:lstrash - list each trashed file
:empty - empty trash
w - toggle preview pane [custom]
<c-w>o - show only one pane (also :only)
<c-w>v - show two panes (vertical split)
<c-w>s - show two panes (horizontal split)
={pattern} - filter file list
zr - clear filter
t - tag (select) current file
ga - directory size
s - same directory (other pane = current page) [custom]
S - other pane directory = current item [custom]