summaryrefslogtreecommitdiff
path: root/.bashrc
blob: e9bb688e246fd6b861e26e8e29edc16e1ad6f794 (plain)
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
leftprompt() {
    e=$?; (( $e )) && r="\[$(tput setaf 1)\]<$e>\[$(tput sgr0)\]" || r="";
    p=$(echo ${PWD:-?} | sed "s#.*/\(.*\)/\(.*\)#\1/\2#"); # s#$HOME#~# #${PWD##*/}
    d=$(date +"%H.%M");
    v=$(vcs);
    u=#; (( $(id -u) )) && u=\$;
    PS1="\[$(tput sgr0)\][\[$(tput bold)\]\h:\[$(tput setaf 30)\]$p\[$(tput sgr0)\]]\
(\[$(tput setaf 32)\]$d\[$(tput sgr0)\])$r$v\[$(tput rev)\]$u\[$(tput sgr0)\] ";
}

PROMPT_COMMAND=leftprompt

case ${TERM} in
  st*|xterm*|rxvt*|Eterm|aterm|kterm|gnome*|alacritty)
     PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033]0;%s\007" "${PWD/#$HOME/\~}"'
    ;;
  screen*|tmux*)
    PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033k%s\033\\" "${PWD/#$HOME/\~}"'
    ;;
esac

alias rm='rm -i'
alias ls='ls --group-directories-first -vF --color=always'
alias hh='cd $HOME'
alias bk='cd $OLDPWD'

alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
alias ......='cd ../../../../..'

alias lower="tr '[:upper:]' '[:lower:]'"
alias upper="tr '[:lower:]' '[:upper:]'"
alias rot13="tr abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM"

mvf() { mv $*; cd $_ ;}
c() { echo 'scale=13;' $* | bc -l; }
j() { ce $*; cd `head -n 1 $HOME/.local/share/dir_lst`; }
hd() { hexdump -e '"%08.8_ax  " 8/1 "%02X " " - " 8/1 "%02X "' -e '"  |" "%_p"' -e '"|\n"' "$@"; }
mkpw() { cat /dev/urandom | tr -dc "[:print:]" | fold -w `[[ "$2" == "" ]] && echo 16 || echo $2` | head -n `[[ "$1" == "" ]] && echo 1 || echo "$1"` ;}

stty -ixon
umask 077

set -o emacs
shopt -s autocd
shopt -s checkwinsize

# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth

# append to the history file, don't overwrite it
shopt -s histappend

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000

+complete -F _command doas # doas completions

# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"