aboutsummaryrefslogtreecommitdiff
path: root/.shellrc
blob: f447f51702b42ba210d0c90a35bd29b60e5112a2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/sh
# shellcheck disable=SC2155


#
# Basics
#

# Disable Ctrl-s Ctrl-q
stty stop undef
stty start undef

# Set hints about shell
[ "$(id -u)" = 0 ] && _IS_ROOT="1"
[ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ] && _IS_SSH="1"


#
# Look and feel
#

# ls colours
LS_IMAGE=":*.ai=00;32:*.arw=00;32:*.avif=00;32:*.bmp=00;32:*.cr2=00;32:*.cr3=00;32:*.crw=00;32:*.dng=00;32:*.gif=00;32:*.heic=00;32:*.heif=00;32:*.ico=00;32:*.jpeg=00;32:*.jpg=00;32:*.jxl=00;32:*.kra=00;32:*.png=00;32:*.psd=00;32:*.qoi=00;32:*.raw=00;32:*.svg=00;32:*.svgz=00;32:*.tif=00;32:*.tiff=00;32:*.webp=00;32:*.xcf=00;32"
LS_DOCUM=":*.cb7=00;32:*.cbr=00;32:*.cbt=00;32:*.cbz=00;32:*.doc=00;32:*.docx=00;32:*.epub=00;32:*.odp=00;32:*.ods=00;32:*.odt=00;32:*.pdf=00;32:*.ppt=00;32:*.pptx=00;32:*.ps=00;32:*.xls=00;32:*.xlsx=00;32"
LS_AUDIO=":*.aac=00;34:*.ac3=00;34:*.alac=00;34:*.flac=00;34:*.m4a=00;34:*.mid=00;34:*.midi=00;34:*.mp3=00;34:*.ogg=00;34:*.opus=00;34:*.wav=00;34:*.wma=00;34:*.wv=00;34:*.wvc=00;34:"
LS_VIDEO=":*.avi=00;34:*.flv=00;34:*.m2ts=00;34:*.mts=00;34:*.mkv=00;34:*.mov=00;34:*.mp4=00;34:*.webm=00;34:*.wmv=00;34"
export LS_COLORS="no=00:di=01;35:ow=01;35:ex=00;33:ln=00;36:or=01;31:mi=01;31${LS_IMAGE}${LS_DOCUM}${LS_AUDIO}${LS_VIDEO}"
unset LS_IMAGE LS_DOCUM LS_AUDIO LS_VIDEO

# less colours
export LESS_TERMCAP_mb="$(printf '\033[0;35m')"
export LESS_TERMCAP_md="$(printf '\033[0;35m')"
export LESS_TERMCAP_me="$(printf '\033[0m')"
export LESS_TERMCAP_so="$(printf '\033[0;30;45m')"
export LESS_TERMCAP_se="$(printf '\033[0m')"
export LESS_TERMCAP_us="$(printf '\033[0;36m')"
export LESS_TERMCAP_ue="$(printf '\033[0m')"

# sudo prompt
export SUDO_PROMPT="$(printf '\033[1;31m')[sudo]$(printf '\033[0m') password for %p: "


#
# Aliases
#

alias ls='ls --color=auto --group-directories-first'
alias vi='nvim'
alias vim='nvim'
alias sudo='sudo '
alias doas='doas '
alias torsocks='torsocks '
alias pip='pip --disable-pip-version-check'
alias pip3='pip3 --disable-pip-version-check'
if command -pv man 1>/dev/null 2>&1; then
	man() {
		if ! command -p man -V 1>/dev/null 2>&1; then
			command -p man -O mdoc "$@"
		else
			command -p man "$@"
		fi
	}
fi

# ffmpeg aliases
alias ffmpeg='ffmpeg -hide_banner'
alias ffplay='ffplay -hide_banner'
alias ffprobe='ffprobe -hide_banner'
alias fflyrics='ffprobe -loglevel error -show_entries format_tags=lyrics -of default=noprint_wrappers=1:nokey=1'

# yt-dlp aliases
alias yt-dlp='yt-dlp -o "%(title)s.%(ext)s"'
alias yt-audio='yt-dlp -f bestaudio -o "%(title)s.%(ext)s"'
alias yt-video='yt-dlp -f bestvideo -o "%(title)s.%(ext)s"'
alias yt-thumbnail='yt-dlp --write-thumbnail --skip-download -o "%(title)s.%(ext)s"'

# mpd aliases
# shellcheck disable=SC2142,SC2154
alias mpd-dedup='mpc playlist -f "%position%\t%file%" | sort -k 2 | perl -ne '\''m/(.*)\t(.*)/; print "$1\n" if $2 eq $prev; $prev=$2'\'' | mpc del'

# flac aliases
alias metaflac-tags='metaflac --list --block-type=VORBIS_COMMENT'