1
0
Fork 0
dotfiles/zsh/aliases
2024-12-02 09:02:00 -08:00

86 lines
2 KiB
Bash

#!/usr/bin/env zsh
alias startx='ssh-agent startx; vlock'
alias l='ls'
alias la='ls -A'
alias ll='ls -l'
alias units='units --verbose'
alias trr='transmission-remote'
alias g='git'
alias rg='rg -S'
alias sg='ast-grep'
# I have never actually meant to start Ghostscript, but I'm sure that I'll want
# to be able to someday.
alias gs='git status'
alias ghostscript="command gs"
alias tf='terraform'
alias timestamp='date "+%Y-%m-%d_%H-%M-%S"'
alias datestamp='date "+%Y-%m-%d"'
alias humantime='date "+%Y-%m-%d %H:%M %z"'
alias unixstamp='date "+%s"'
alias jsstamp='date "+%s%3N"'
alias isostamp='date --iso-8601=seconds'
alias filestamp='date --utc "+%Y%m%dT%H%M%S"'
docker-ip() {
docker inspect "$1" --format='{{.NetworkSettings.Networks.bridge.IPAddress}}'
}
alias shrug='echo -n "¯\\_(ツ)_/¯"'
fe() {
local files
IFS=$'\n' files=($(fd --type=f --hidden | fzf --bind='tab:toggle+up,shift-tab:toggle+down' --query="$1" --multi --exit-0))
if [[ -n "${files}" ]]; then
print -s "${EDITOR:-vim}" "${files[@]}"
${EDITOR:-vim} "${files[@]}"
fi
}
qrencode() {
if [ "$#" -gt 0 ]; then
printf "$*" | curl -F=\<- qrenco.de
else
curl -F=\<- qrenco.de
fi
}
wttr() {
local request="wttr.in/$1"
# Narrow output for narrow terminals
[ "$(tput cols)" -lt 125 ] && request+='?n'
curl -H "Accept-Language: ${LANG%_*}" --compressed "$request"
}
mov2gif() {
local infile="$1"
local outfile=''
if [ "$#" -gt 1 ]; then
outfile="$2"
else
outfile="${1%.mov}.gif"
fi
ffmpeg -i "${infile}" -vf scale=800:-1 -r 10 -f image2pipe -vcodec ppm - | convert -delay 5 -layers Optimize -loop 0 - "${outfile}"
echo "${outfile}"
}
relpath() {
realpath --relative-to=. "$1"
}
img-placeholder() {
local size="$1" # WxH
local outfile=''
if [ "$#" -gt 1 ]; then
outfile="$2"
else
outfile="${size}.png"
fi
magick -size "${size}" -background lime -gravity Center caption:"${size}" "${outfile}"
echo "${outfile}"
}