kshrc (2636B)
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 alias objdump='objdump --disassembler-color=on' 43 44 # managing dotfiles 45 alias rice='git --git-dir=~/.local/repos/dotfiles --work-tree=~' 46 47 # youtube-dl 48 alias yt="yt-dlp" 49 alias ytbest="yt -f '(bestvideo+bestaudio)/best'" 50 alias ytmus='mpv --profile=ytmus --shuffle "$YT_MUS"' 51 alias ytab='yt --config-location ~/.config/youtube-dl/audiobooks' 52 53 alias pwgen='pwgen -Cnsy' 54 55 rmimg() { 56 for file; do 57 echo "removing image metadata from: $file" 58 case $file in 59 *.flac) 60 metaflac --remove --block-type=PICTURE "$file" 61 ;; 62 *.mp3) 63 eyeD3 --remove-all-images "$file" 64 ;; 65 esac 66 done 67 } 68 69 rmlist() { 70 IFS=' 71 ' 72 for list; do 73 for file in $(cat "$list"); do 74 rm "$file" 75 done 76 done 77 } 78 79 toutf8() { 80 tmpfile=$(mktemp) 81 for file; do 82 iconv -f $(uchardet "$file") -t UTF-8 "$file" >| "$tmpfile" 83 mv "$tmpfile" "$file" 84 done 85 } 86 87 if [ $UNAME == "OpenBSD" ]; then 88 alias dhclient='doas /sbin/dhclient' 89 alias ifconfig='doas /sbin/ifconfig' 90 91 alias cc='cc -O3 -pipe -Weverything -Werror -pedantic-errors -std=c99' 92 alias c++='c++ -O3 -pipe -Weverything -Werror' 93 fi 94 95 if [ -f /etc/gentoo-release ]; then 96 alias tcc='tcc -Wall -Werror' 97 alias cc='cc -O3 -pipe -Wall -Werror -pedantic-errors -std=c99' 98 alias c++='c++ -O3 -pipe -Wall -Werror' 99 alias em='doas /usr/bin/emerge' 100 alias ifconfig='doas /bin/ifconfig' 101 fi 102 103 if [ -f /etc/arch-release ]; then 104 alias pm='doas /usr/bin/pacman' 105 fi 106 107 ############### 108 # Completions # 109 ############### 110 if [ -f /etc/gentoo-release -o $UNAME == "OpenBSD" ]; then 111 set -A complete_ifconfig_1 -- $(ifconfig | sed -n '/^[a-z]/s,:.*,,p') 112 fi 113 114 if [ $UNAME == "OpenBSD" ]; then 115 PKG_LIST=$(ls /var/db/pkg) 116 set -A complete_pkg_delete -- $PKG_LIST 117 set -A complete_pkg_info -- $PKG_LIST 118 119 set -A complete_mixerctl -- $(mixerctl | sed 's:=.*$::') 120 set -A complete_sysctl -- $(sysctl | sed 's:=.*$::') 121 set -A complete_rcctl_2 -- $(rcctl ls all) 122 fi