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 ossh='ssh -o "SetEnv TMUX=off"'
 22if [[ -x "$(command -v fzf)" && -x "$(command -v sshhosts)" ]]; then
 23	alias sshgrep='ssh ${$(sshhosts -s |fzf --height=~50| awk '"'"'{print $1}'"'"'):--V}'
 24fi
 25
 26###############################
 27# generate random password
 28function _passgen() {
 29  local chars numbers lowers uppers
 30	chars='!@?%^_=*#&'
 31  numbers='0123456789'
 32  lowers='abcdefghijklmnopqrstuvwxyz'
 33  uppers='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
 34	length=$1
 35	
 36	{ </dev/urandom LC_ALL=C grep -ao '[A-Za-z0-9!@?%^_=*#&]' \
 37		  | head -n$((length-4))
 38	  echo ${chars:$((RANDOM % ${#chars})):1}   # Random special char.
 39    echo ${numbers:$((RANDOM % ${#numbers})):1}
 40    echo ${lowers:$((RANDOM % ${#lowers})):1}
 41    echo ${uppers:$((RANDOM % ${#uppers})):1}
 42	} | shuf | tr -d '\n'
 43}
 44
 45function passgen() {
 46	local o_copy o_help
 47	local usage=(
 48		"$0 [-h|--help]"
 49		"$0 [-c|--copy] [length]"
 50	)
 51
 52	zmodload zsh/zutil
 53	zparseopts -D -F -K -- \
 54		   {h,-help}=o_help \
 55		   {c,-copy}=o_copy || return 1
 56
 57	[[ -z "$o_help" ]] || { print -l $usage && return }
 58
 59	_pass=`_passgen ${1:=$((RANDOM %8 + 10))}`
 60	[[ -z "$o_copy" ]] || { echo $_pass | wl-copy -n }
 61	
 62	echo $_pass
 63}
 64###############################
 65# SSH
 66alias 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 $@'
 67
 68###############################
 69# pastebin clients
 70function cpb () {
 71	wl-paste | pb $@
 72}
 73function pbd() {
 74	curl -XDELETE ${KPASTE_HOST:-"https://pb.koi.moe"}/$1
 75}
 76
 77function ix() {
 78	local opts
 79	local OPTIND
 80	[ -f "$HOME/.netrc" ] && opts='-n'
 81	while getopts ":hd:i:n:" x; do
 82		case $x in
 83			h) echo "ix [-d ID] [-i ID] [-n N] [opts]"; return;;
 84			d) $echo curl $opts -X DELETE ix.io/$OPTARG; return;;
 85			i) opts="$opts -X PUT"; local id="$OPTARG";;
 86			n) opts="$opts -F read:1=$OPTARG";;
 87		esac
 88	done
 89	shift $(($OPTIND - 1))
 90	[ -t 0 ] && {
 91		local filename="$1"
 92		shift
 93		[ "$filename" ] && {
 94			curl $opts -F f:1=@"$filename" $* ix.io/$id
 95			return
 96		}
 97		echo "^C to cancel, ^D to send."
 98	}
 99	curl $opts -F f:1='<-' $* ix.io/$id
100}
101
102function farsee() {
103	local file=${1:-/dev/stdin}
104	curl -F "c=@${file}" "https://fars.ee/"
105}
106
107###############################
108# Weather
109function wt() {
110	local city=${1:-"Wuhan"}
111	curl -s "wttr.in/$city?T"
112}