~~Handy Commands~~


Some useful commands I use regularly, will add to this as I find more



Unlock files in Mac OS: chflags -R nouchg

Find out which Applications are hogging a drive: sudo lsof +D /Volumes/[name of drive]

Set up and install SSH keys: ssh-keygen; ssh-add --apple-use-keychain [path to private key]; ssh-copy-id [user@server]

Delete all files of a certain type (recursively): find . -name "*.[type]" -type f -delete


Some nice options for .zshrc

setopt HIST_IGNORE_ALL_DUPS #don't repeat commands in history

setopt PROMPT_SUBST #make the prompt decent

PROMPT='%F{red}%n%F{yellow}@%f%F{green}%m%f:%F{cyan}%~%f%# '


Download .emacs file with all the below options included: wget puyoman.net/.emacs

Stop emacs from putting autosave/backup files all over the place (.emacs file in home directory)

;;; backup/autosave

(defvar backup-dir (expand-file-name "~/.emacs.d/backup/"))

(defvar autosave-dir (expand-file-name "~/.emacs.d/autosave/"))

(setq backup-directory-alist (list (cons ".*" backup-dir)))

(setq auto-save-list-file-prefix autosave-dir)

(setq auto-save-file-name-transforms `((".*" ,autosave-dir t)))


Save last position in emacs

(save-place-mode 1)


Use alt (M) + up/down to scroll the screen up and down one line in emacs

(global-set-key [M-down] (lambda () (interactive) (scroll-up 1)))

(global-set-key [M-up] (lambda () (interactive) (scroll-down 1)))


Aliases for creating and extracting tar archives

alias unarchive="tar -xvzf"

alias archive="tar -czvf"


Search files by content: grep -Rnw path -e pattern or grep -r pattern if already in directory to be searched


Create symbolic link: ln -s [path to existing file] [path of link to be created]


Copy symbolic link without copying actual file: cp -P


Force yt-dlp to use workable formats: yt-dlp ${url} -f "bestvideo*[vcodec^=avc]+bestaudio[ext=m4a]/best[ext=mp4]/best"

Alias for .zshrc: alias yt-dlp="yt-dlp -f \"bestvideo*[vcodec^=avc]+bestaudio[ext=m4a]/best[ext=mp4]/best\""


back    home