radare2rc, dwmcolors, vimrc
[dotfiles_afify.git] / .config / ksh / kshrc
blob5559f3a6f69dcec9353e560ede4870948f538381
1 #!/bin/ksh
3 alias k='clear'
4 alias du="du -sh"
5 alias df="df -h"
6 alias mv='mv -i'
7 alias cp='cp -ir'
8 alias rm='rm -i'
9 alias mkdir='mkdir -p'
10 alias xc='xclip -sel clip'
11 alias fonts=" fc-list | sed 's/^.*: //' | awk -F: '{print $1}' | sort | uniq"
12 alias lsb="dmesg | egrep '^(cd|wd|sd|fd). at ' | sort | uniq"
13 alias sc="rsync -avzhe ssh --progress"
14 alias cpp="rsync -avzhe --progress"
15 [ "$(uname)" = "OpenBSD" ] && alias ulocate="doas /usr/libexec/locate.updatedb"
16 [ "$(uname)" = "OpenBSD" ] && alias gr='grep -Inr' || alias gr='grep -Inr --color=always'
18 # development
19 [ "$(uname)" = "Linux" ] && valf='-s'
20 alias val="valgrind --trace-children=yes --track-fds=yes --track-origins=yes --leak-check=full --show-leak-kinds=all $valf"
21 [ "$(uname)" = "OpenBSD" ] && alias sys="less /sys/sys/syscall.h" || alias sys="bat /usr/include/asm/unistd_64.h"
22 [ "$(uname)" = "OpenBSD" ] && alias sys2="less /usr/src/sys/kern/syscalls.master"
23 alias ob="objdump -D -M intel"
24 alias rr="r2 -d -c vv"
25 alias reg="cat .scripts/reg.txt"
27 # downloads
28 alias wgetf="wget --tries=100 --continue --content-disposition --trust-server-names -i"
29 alias wgetw="wget -r -l inf"
30 alias egyb=" cd ~/downloads && python /mnt/data/dev/archived/egybest_downloader/egybest_unix.py"
32 # youtube
33 yt="youtube-dl -i --add-metadata"
34 alias ya="$yt -f bestaudio"
35 alias yv4="$yt -f 'bestvideo[height<=480]+bestaudio/best[height<=480]'"
36 alias yv7="$yt -f 'bestvideo[height<=720]+bestaudio/best[height<=720]'"
37 alias yvp4="yv4 -o \"%(autonumber)s-%(title)s.%(ext)s\""
38 alias yvp7="yv7 -o \"%(autonumber)s-%(title)s.%(ext)s\""
40 # ls
41 [ "$(uname)" = "OpenBSD" ] && alias ls='colorls -GA' || alias ls='ls --color=always -A'
42 alias ll='ls -lh'
44 # prompt
45 [ "$(id -u)" = 0 ] && col="9m" || col="24m"
46 export PS1="\[\033[38;5;$col\]\W \033[38;5;166m\]\$(git branch --show-current 2>/dev/null)\[\033[00m\] "
48 # extract
49 ex(){
50 [ -f "$1" ] && case $1 in
51 *.tar.bz2) tar xjf "$1";;
52 *.tar.gz) tar xzf "$1";;
53 *.tar.xz) tar xf "$1";;
54 *.tar.zst) tar -I zstd -xvf "$1";;
55 *.tar) tar xf "$1";;
56 *.tbz2) tar xjf "$1";;
57 *.tgz) tar xzf "$1";;
58 *.xz) xz -d "$1";;
59 *.bz2) bunzip2 "$1";;
60 *.rar) unrar x "$1";;
61 *.gz) gunzip "$1";;
62 *.zip) unzip "$1";;
63 *.7z) 7z x "$1";;
64 *.Z) uncompress "$1";;
65 *) echo "'$1' cannot be extracted.";;
66 esac
69 cf(){
70 cp /mnt/data/dev/openbsd_clang-format/.clang-format .
71 clang-format -style=file -i $1
72 rm -f .clang-format
75 xd(){
76 echo "ibase=16;obase=A;$1" | bc
79 dx(){
80 echo "ibase=A;obase=16;$1" | bc
83 g(){
84 gr "$1" "$2" | less -R
87 comp(){
88 dir=$(basename "$1")
89 [ -f "$1" ] || [ -d "$1" ] && tar -czvf "$dir.tar.gz" -C "$1/.." "$dir"
92 fixp(){
93 [ -f "$1" ] || [ -d "$1" ] &&
94 find "$1" -type d -exec chmod 700 {} \; &&
95 find "$1" -type f -exec chmod 600 {} \; &&
96 chown -R $USER "$1" && chgrp -R $USER "$1"