dotfiles

Alpine Linux dotfiles

git clone git://git.lin.moe/dotfiles.git

  1alias ls='ls --color=auto'
  2alias l='ls'
  3alias ll='ls -lh'
  4
  5
  6[ -x "$(command -v helix)" ] && alias hx='helix'
  7
  8alias tt='tmux new -A -s'
  9
 10alias task='go-task'
 11
 12alias de='doasedit'
 13
 14alias rs='rsync -rz --info=progress2'
 15alias rrs='RSYNC_PASSWORD=$(pass tool/rsyncd/lindsay) rsync-ssl -rz --info=progress2'
 16
 17alias ppgrep='ps aux | grep -v grep |  grep $@'
 18
 19[ -x "$(command -v edit)" ] && alias e=edit
 20
 21alias ssh-gpg='ssh -f -N -o ControlPath="$HOME/.ssh/controlmaster/%n|$o_addr|%r@%h|%p.gpg" -o RemoteForward="$HOME/.gnupg/S.gpg-agent $HOME/.gnupg/S.gpg-agent.extra"'
 22
 23###############################
 24# generate random password
 25function _passgen() {
 26  local chars numbers lowers uppers
 27	chars='!@?%^_=*#&'
 28  numbers='0123456789'
 29  lowers='abcdefghijklmnopqrstuvwxyz'
 30  uppers='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
 31	length=$1
 32	
 33	{ </dev/urandom LC_ALL=C grep -ao '[A-Za-z0-9!@?%^_=*#&]' \
 34		  | head -n$((length-4))
 35	  echo ${chars:$((RANDOM % ${#chars})):1}   # Random special char.
 36    echo ${numbers:$((RANDOM % ${#numbers})):1}
 37    echo ${lowers:$((RANDOM % ${#lowers})):1}
 38    echo ${uppers:$((RANDOM % ${#uppers})):1}
 39	} | shuf | tr -d '\n'
 40}
 41
 42function passgen() {
 43	local o_copy o_help
 44	local usage=(
 45		"$0 [-h|--help]"
 46		"$0 [-c|--copy] [length]"
 47	)
 48
 49	zmodload zsh/zutil
 50	zparseopts -D -F -K -- \
 51		   {h,-help}=o_help \
 52		   {c,-copy}=o_copy || return 1
 53
 54	[[ -z "$o_help" ]] || { print -l $usage && return }
 55
 56	_pass=`_passgen ${1:=$((RANDOM %8 + 10))}`
 57	[[ -z "$o_copy" ]] || { echo $_pass | wl-copy -n }
 58	
 59	echo $_pass
 60}
 61###############################
 62# SSH
 63alias ssh-mount='sshfs -o uid=$(id -u) -o gid=$(id -g) -o allow_root -o remember=20 -o sync_readdir -o sshfs_sync -o reconnect $@'
 64
 65###############################
 66# pastebin clients
 67function cpb () {
 68	wl-paste | pb $@
 69}
 70function pbd() {
 71	curl -XDELETE ${KPASTE_HOST:-"https://pb.koi.moe"}/$1
 72}
 73
 74function ix() {
 75	local opts
 76	local OPTIND
 77	[ -f "$HOME/.netrc" ] && opts='-n'
 78	while getopts ":hd:i:n:" x; do
 79		case $x in
 80			h) echo "ix [-d ID] [-i ID] [-n N] [opts]"; return;;
 81			d) $echo curl $opts -X DELETE ix.io/$OPTARG; return;;
 82			i) opts="$opts -X PUT"; local id="$OPTARG";;
 83			n) opts="$opts -F read:1=$OPTARG";;
 84		esac
 85	done
 86	shift $(($OPTIND - 1))
 87	[ -t 0 ] && {
 88		local filename="$1"
 89		shift
 90		[ "$filename" ] && {
 91			curl $opts -F f:1=@"$filename" $* ix.io/$id
 92			return
 93		}
 94		echo "^C to cancel, ^D to send."
 95	}
 96	curl $opts -F f:1='<-' $* ix.io/$id
 97}
 98
 99function farsee() {
100	local file=${1:-/dev/stdin}
101	curl -F "c=@${file}" "https://fars.ee/"
102}
103
104###############################
105# Weather
106function wt() {
107	local city=${1:-"Wuhan"}
108	curl -s "wttr.in/$city?T"
109}