dotfiles/.aliases.sh
2025-01-11 20:09:27 +02:00

144 lines
3.3 KiB
Bash

# Common aliases.
# Add `source ~/.aliases.sh` to your shell cfg.
export PATH=$PATH:$HOME/bin:$HOME/.cargo/bin:$HOME/.local/bin
export HISTSIZE=100
# jump 1 word with ctrl-arrow in some terminals
bindkey "^[[1;5C" forward-word
bindkey "^[[1;5D" backward-word
function process-audio() {
if [ "$#" -ne 1 ]; then
echo "Invalid number of parameters"
echo "usage: process-audio <source>"
return
fi
COMPRESSED="${1%.*}-cmp.wav"
NORMALIZED="${1%.*}-norm.mp3"
echo ""
echo "COMPRESSING"
ffmpeg -i "$1" \
-c:a pcm_s16le \
-af "acompressor=threshold=-24dB:attack=3:release=20:ratio=3" \
"$COMPRESSED"
echo ""
echo "NORMALIZING"
ffmpeg-normalize "$COMPRESSED" \
-o "$NORMALIZED" \
-c:a mp3 \
-b:a 128k \
-ar 44100 \
-t -16 \
-tp -2 \
-lrt 7 \
--dual-mono \
-f -pr
rm "$COMPRESSED"
}
function update-system() {
sudo pacman -Syu
yay -Syu
rustup update
}
function screen_brightness_wlroots() {
brightness="${1:-1}"
temp="${2:-6500}"
pkill -f "gammastep"
gammastep -b "$brightness" -O "$temp" &
}
function screen_brightness_x11() {
redshift -x
brightness="${1:-1}"
temp="${2:-6500}"
xrandr --output DP-1 --brightness "$brightness"
xrandr --output DP-3 --brightness "$brightness"
redshift -O "$temp"
}
function screen_brightness() {
if [ "$XDG_SESSION_TYPE" = "x11" ]; then
screen_brightness_x11 "$@"
else
screen_brightness_wlroots "$@"
fi
}
alias sb=screen_brightness
function upload() {
if [ "$#" -ne 2 ]; then
echo "Invalid number of parameters"
echo "usage: upload <target_dir> <file>"
echo "example: upload tmp img.png"
return
fi
if [ -z "$RSYNC_HOST" ]; then
echo "No rsync env variables set, did you forget to source?"
return
fi
echo "Uploading to $1/$2"
rsync \
--verbose \
--recursive \
--rsh "ssh -p $RSYNC_PORT -i $HOME/.ssh/$RSYNC_KEY" \
"$2" \
"$RSYNC_USER@$RSYNC_HOST:$RSYNC_DEST/$1"
if [ "$?" -ne 0 ]; then
return
fi
echo ""
echo "https://$RSYNC_HOST/$1/$2 (copied to clipboard)"
echo "https://$RSYNC_HOST/$1/$2" | xclip -sel clip
}
function upload_all() {
for X in *; do
upload $1 $X
done
}
function randomize-filenames() {
for X in *; do
if [ -f "$X" ]; then
EXT="${X##*.}"
FILENAME=$(cat /dev/urandom | tr -cd 'a-f0-9' | head -c 16)
mv --no-clobber --verbose "$X" "$FILENAME.$EXT"
fi
done
}
alias remove_exif="mogrify -verbose -strip *.jpg"
alias tf2="steam -applaunch 440 -noborder -windowed -w 1920 -h 1080 +fps_max 240"
alias ga="git add"
alias gts="git status"
alias gd="git diff"
alias gp="git push"
alias gpf="git push --force-with-lease"
alias gpl="git pull"
alias gc="git commit"
alias gup="git fetch && git pull && git submodule update --recursive"
alias greb="git fetch && git pull && git rebase origin/master"
alias ls="eza --long --all --header --group --icons=always"
alias mkdir="mkdir -p"
alias hx=helix
alias disc="firejail discord --ignore-gpu-blocklist --disable-features=UseOzonePlatform --enable-features=VaapiVideoDecoder --use-gl=desktop --enable-gpu-rasterization --enable-zero-copy"