dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles
Log | Files | Refs | README | LICENSE

commands (3564B)


      1 #!/bin/sh
      2 
      3 alias e='$EDITOR'
      4 
      5 f() {
      6 	$EDITOR $(find "${1:-.}" -type f | fzy -l 25)
      7 }
      8 
      9 if type doas >/dev/null 2>&1; then
     10 	alias se='doas $EDITOR'
     11 else
     12 	alias se='sudo $EDITOR'
     13 fi
     14 alias n='$FILE'
     15 alias sx="sxiv -ft *"
     16 
     17 alias xq="xbps-query"
     18 alias xr="sudo xbps-remove"
     19 
     20 c() {
     21 	dir=$(find "${1:-.}" -type d | grep -v '/\.' | fzy -l 25)
     22 	[ -d "$dir" ] && cd "$dir" || return
     23 }
     24 alias cg='c "$(git rev-parse --show-toplevel)"'  # cd under git repo
     25 
     26 alias r='fc -s'
     27 
     28 h() {
     29 	eval $(cat "$HISTFILE" | fzy -l 25)
     30 }
     31 
     32 o() {
     33 	[ "$(uname)" = 'Darwin' ] && open="open" || open="xdg-open"
     34 	if [ "$#" -gt 0 ] && [ -f "$1" ]; then
     35 		$open "$1"
     36 	else
     37 		target="$(find "${1:-.}" | fzy -l 25)"
     38 		if [ -f "$target" ]; then
     39 			$open "$target"
     40 		elif [ -d "$target" ]; then
     41 			cd "$target"
     42 		else
     43 			(>&2 echo "unknown target type")
     44 		fi
     45 	fi
     46 }
     47 
     48 alias ls=ls; unalias ls
     49 alias ls='ls -hF'
     50 alias l='ls'
     51 alias la='l -a'
     52 alias ll='l -l'
     53 alias lo='l -alo'
     54 
     55 alias dot="git --git-dir=\$HOME/.dotfiles/ --work-tree=\$HOME"
     56 alias dotcap="dot commit -a -S -v; dot push"
     57 
     58 alias m="make"
     59 alias mc="make clean"
     60 alias me="make edit"
     61 if type doas >/dev/null 2>&1; then
     62 	alias mi="doas make install"
     63 else
     64 	alias mi="sudo make install"
     65 fi
     66 
     67 alias date-denmark='TZ=Europe/Copenhagen date'
     68 alias date-eastern='TZ=US/Eastern date'
     69 alias date-pacific='TZ=US/Pacific date'
     70 alias date-mountain='TZ=US/Mountain date'
     71 alias date-central='TZ=US/Central date'
     72 alias date-alaska='TZ=US/Alaska date'
     73 alias date-uk='TZ=Europe/London date'
     74 alias date-israel='TZ=Israel date'
     75 alias now="linkhandler https://imgs.xkcd.com/comics/now.png"
     76 
     77 alias gs='git s'
     78 alias gss='git ss'
     79 alias ga='git add'
     80 alias gd='git diff --'
     81 alias gch='git diff HEAD^..HEAD'
     82 alias gc='git commit --verbose --gpg-sign'
     83 alias gca='git commit --all --verbose --gpg-sign'
     84 alias gp='git push'
     85 alias gpu='git pull && git fetch --all'
     86 alias gcgp='git commit --verbose --gpg-sign && git push'
     87 alias gcagp='git commit --all --verbose --gpg-sign && git push'
     88 alias gl="git log --graph --oneline --decorate --all --color=always |
     89 	fzf --ansi +s --preview='git show --color=always {2}' \
     90 	--bind='pgdn:preview-page-down' \
     91 	--bind='pgup:preview-page-up' \
     92 	--bind='enter:execute:git show --color=always {2} | less -R' \
     93 	--bind='ctrl-x:execute:git checkout {2} .'"
     94 
     95 alias w3m="w3m -B"
     96 alias w3mtor='torsocks w3m -B "$@"'
     97 
     98 alias wanip='curl https://ipinfo.io/ip'
     99 news() {
    100 	if [ $# -eq 0 ]; then
    101 		url="https://text.npr.org"
    102 	elif [ "$1" = "npr" ]; then
    103 		url="https://text.npr.org"
    104 	elif [ "$1" = "cnn" ]; then
    105 		url="https://lite.cnn.io/en"
    106 	else
    107 		url="$1"
    108 	fi
    109 	torsocks w3m "$url"
    110 }
    111 weather() { curl "wttr.in/?m"; }
    112 
    113 t_add() { transmission-remote --add --download-dir "$PWD" --encryption-required "$@"; }
    114 t_list() { transmission-remote --list; }
    115 t_remove() { transmission-remote --torrent "$@" --remove; }
    116 t_remove_all() { transmission-remote -tall --remove; }
    117 t_stop() { transmission-remote --torrent "$@" --stop; }
    118 t_stop_idle() {
    119 	for id in $(t-list | grep Done | grep Idle | awk '{ print $1 }' | tr '\n' ','); do
    120 		t-stop "$id"
    121 	done
    122 }
    123 
    124 man9() {
    125 	if [ -d /usr/lib/plan9 ]; then
    126 		plan9mans="/usr/lib/plan9/man/man1"
    127 	elif [ -d /opt/plan9 ]; then
    128 		plan9mans="/opt/plan9/share/man/man1"
    129 	elif [ -d /usr/local/plan9 ]; then
    130 		plan9mans="/usr/local/plan9/man/man1"
    131 	else
    132 		(>&2 echo "no plan9 port installed")
    133 		return 1
    134 	fi
    135 	m="$1"
    136 	if [ $# -lt 1 ]; then
    137 		m="$(cd "$plan9mans" && find -- * -type f | sed 's/\.1$//' | fzy)"
    138 	fi
    139 	f="$plan9mans/${m}.1"
    140 	echo "$f"
    141 	[ -e "$f" ] && man "$f"
    142 }
    143 
    144 alias julia-fast='julia --procs 1 --optimize=3 --math-mode=fast'