kshrc (2588B)
1 set -C 2 set -o vi 3 4 UNAME="$(uname -s)" 5 6 KSHDIR=~/.config/ksh 7 8 ######################### 9 # Environment Variables # 10 ######################### 11 [ -f $KSHDIR/local ] && . $KSHDIR/local 12 [ -f $KSHDIR/kshenv ] && . $KSHDIR/kshenv 13 14 export PS4='$(tput bold)\$>$(tput sgr0) ' 15 PS1='$(tput bold)\W \$$(tput sgr0) ' 16 if [ -n "$SSH_CONNECTION" ]; then 17 PS1="(\h) $PS1" 18 fi 19 20 if [ $UNAME == "OpenBSD" ]; then 21 ulimit -c 0 22 fi 23 24 if [ $UNAME == "Linux" ]; then 25 if [ -z "$DISPLAY" ] && [ "$(tty)" = "/dev/tty1" ]; then 26 startx ~/.config/x11/xinitrc 27 fi 28 fi 29 30 ########### 31 # Aliases # 32 ########### 33 [ -f "$KSHDIR/shortcuts" ] && . "$KSHDIR/shortcuts" 34 35 alias c=clear 36 alias e="$EDITOR" 37 alias v="$EDITOR" 38 alias ll='ls -lh' 39 alias mkdir='mkdir -p' 40 alias mvi='mpv --profile=image' 41 alias ncmpcpp='tput smkx && ncmpcpp' 42 43 # managing dotfiles 44 alias rice='git --git-dir=~/.local/repos/dotfiles --work-tree=~' 45 46 # youtube-dl 47 alias yt="yt-dlp" 48 alias ytbest="yt -f '(bestvideo+bestaudio)/best'" 49 alias ytmus='mpv --profile=ytmus --shuffle "$YT_MUS"' 50 alias ytab='yt --config-location ~/.config/youtube-dl/audiobooks' 51 52 alias pwgen='pwgen -Cnsy' 53 54 rmimg() { 55 for file; do 56 echo "removing image metadata from: $file" 57 case $file in 58 *.flac) 59 metaflac --remove --block-type=PICTURE "$file" 60 ;; 61 *.mp3) 62 eyeD3 --remove-all-images "$file" 63 ;; 64 esac 65 done 66 } 67 68 rmlist() { 69 IFS=' 70 ' 71 for list; do 72 for file in $(cat "$list"); do 73 rm "$file" 74 done 75 done 76 } 77 78 toutf8() { 79 tmpfile=$(mktemp) 80 for file; do 81 iconv -f $(uchardet "$file") -t UTF-8 "$file" >| "$tmpfile" 82 mv "$tmpfile" "$file" 83 done 84 } 85 86 if [ $UNAME == "OpenBSD" ]; then 87 alias dhclient='doas /sbin/dhclient' 88 alias ifconfig='doas /sbin/ifconfig' 89 90 alias cc='cc -O3 -pipe -Weverything -Werror -pedantic-errors -std=c99' 91 alias c++='c++ -O3 -pipe -Weverything -Werror' 92 fi 93 94 if [ -f /etc/gentoo-release ]; then 95 alias tcc='tcc -Wall -Werror' 96 alias cc='cc -O3 -pipe -Wall -Werror -pedantic-errors -std=c99' 97 alias c++='c++ -O3 -pipe -Wall -Werror' 98 alias em='doas /usr/bin/emerge' 99 alias ifconfig='doas /bin/ifconfig' 100 fi 101 102 if [ -f /etc/arch-release ]; then 103 alias pm='doas /usr/bin/pacman' 104 fi 105 106 ############### 107 # Completions # 108 ############### 109 if [ -f /etc/gentoo-release -o $UNAME == "OpenBSD" ]; then 110 set -A complete_ifconfig_1 -- $(ifconfig | sed -n '/^[a-z]/s,:.*,,p') 111 fi 112 113 if [ $UNAME == "OpenBSD" ]; then 114 PKG_LIST=$(ls /var/db/pkg) 115 set -A complete_pkg_delete -- $PKG_LIST 116 set -A complete_pkg_info -- $PKG_LIST 117 118 set -A complete_mixerctl -- $(mixerctl | sed 's:=.*$::') 119 set -A complete_sysctl -- $(sysctl | sed 's:=.*$::') 120 set -A complete_rcctl_2 -- $(rcctl ls all) 121 fi