aboutsummaryrefslogtreecommitdiff
path: root/.bashrc
blob: 8f131837920aa575f46d0cfc5fe584aa205acdaf (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/bash

# source exports
export BASH_PROFILE=loaded && . "$HOME/.bash_profile";

# bail if not interactive
[[ $- != *i* ]] && return;

# cd using directory name
shopt -s autocd;

# append bash history entries
shopt -s histappend;

# bash history one command per line
shopt -s cmdhist;

# enable vi mode
set -o vi;

# disable ctrl+s
stty stop '';
stty start '';
stty -ixon;
stty -ixoff;

# fzf bindings
[ -f '/usr/share/fzf/completion.bash' ] && . /usr/share/fzf/completion.bash
[ -f '/usr/share/fzf/key-bindings.bash' ] && . /usr/share/fzf/key-bindings.bash
[ -f '/usr/share/doc/fzf/examples/completion.bash' ] && . /usr/share/doc/fzf/examples/completion.bash
[ -f '/usr/share/doc/fzf/examples/key-bindings.bash' ] && . /usr/share/doc/fzf/examples/key-bindings.bash

# set virtual console colors
if [ "$TERM" = "linux" ]; then
  echo -en "\e]P0111111" #black [background]
  echo -en "\e]P1D84F4F" #darkred
  echo -en "\e]P2DEFF3E" #darkgreen
  echo -en "\e]P3FFDF23" #brown
  echo -en "\e]P479AEFF" #darkblue
  echo -en "\e]P58894CF" #darkmagenta
  echo -en "\e]P679AEFF" #darkcyan
  echo -en "\e]P7dddddd" #lightgray
  echo -en "\e]P8DDDDDD" #darkgray
  echo -en "\e]P9E84F4F" #red
  echo -en "\e]PABEFF3E" #green
  echo -en "\e]PBFEA63C" #yellow
  echo -en "\e]PC69AEFF" #blue
  echo -en "\e]PD9894CF" #magenta
  echo -en "\e]PE69AEFF" #cyan
  echo -en "\e]PFffffff" #white [foreground]
  clear #for background artifacting
fi

# color man
man() {
  env LESS_TERMCAP_mb="$(printf "\e[1;31m")" \
  LESS_TERMCAP_md="$(printf "\e[1;31m")" \
  LESS_TERMCAP_me="$(printf "\e[0m")" \
  LESS_TERMCAP_se="$(printf "\e[0m")" \
  LESS_TERMCAP_so="$(printf "\e[1;44;33m")" \
  LESS_TERMCAP_ue="$(printf "\e[0m")" \
  LESS_TERMCAP_us="$(printf "\e[1;32m")" \
  man "$@"
}

# ssh agent with keychain
alias ssh='eval $(keychain --eval --agents ssh -Q --quiet ~/.ssh/mobile ~/.ssh/primary) && ssh'

# parenting
alias mv='mv -i'
alias cp='cp -i'
alias ln='ln -i'
alias rm='rm -I --preserve-root'
alias chown='chown --preserve-root'
alias chmod='chmod --preserve-root'
alias chgrp='chgrp --preserve-root'

# general aliases
alias locate='locate -ie'
alias wavemon='sudo wavemon'
alias pacman='sudo pacman'
alias grep='grep --color=tty -d skip'
alias alsamixer='alsamixer -V all'
alias dmesg='dmesg -e'
alias diceware='diceware -d " "'
alias colortest='msgcat --color=test'
alias rangerinf='while true; do ranger; done'
alias archey3="archey3 --config=~/.config/archey3.cfg"
alias wget='wget --hsts-file $HOME/.cache/wget.history'
alias ls='ls -hN --color=always --group-directories-first'
alias lsblk='lsblk -o NAME,MAJ:MIN,RM,SIZE,FSTYPE,RO,TYPE,MOUNTPOINT,MODEL'
alias emacs='TERM=xterm-256color emacs -nw --load ~/.config/emacs/emacs.el'
alias mocp='mocp -M "$XDG_CONFIG_HOME"/moc'

# pulse delay on audacity
alias audacity='PULSE_LATENCY_MSEC=30 audacity'

# lxc helpers
alias lxc-attach='lxc-attach --clear-env -n'
alias lxc-ls='lxc-ls -f'
lxc-copy() { $(which lxc-copy) -n "$1" -N "$2"; }
lxc-restart() { $(which lxc-stop) -n "$1"; $(which lxc-start) -n "$1"; }
lxc-start() { for container in "$@"; do $(which lxc-start) -n "$container"; done }
lxc-stop() { for container in "$@"; do $(which lxc-stop) -n "$container"; done }

# docker aliases
alias pdf2htmlEX='docker run -ti --rm -v "$PWD":/pdf bwits/pdf2htmlex:1.0 pdf2htmlEX'
alias composer='docker run -ti --rm -v $PWD:/app composer:1.8.6 composer'
alias npm='docker run -ti --rm -v "$PWD":/usr/src/app -w /usr/src/app node:12.7.0-alpine npm'
alias pgloader="docker run --rm dimitri/pgloader:latest pgloader"

# source fzm
[ -f "$HOME/.config/fzf-marks/fzf-marks.plugin.bash" ] && . "$HOME/.config/fzf-marks/fzf-marks.plugin.bash"

# remove bash history duplicates
history-remove-duplicates() { awk '!visited[$0]++' "$HOME/.bash_history" > /tmp/.bash_history.tmp && mv -f /tmp/.bash_history.tmp "$HOME/.bash_history"; }

# extract docker container as rootfs
docker-rootfs() { id=$(docker run -d "$1" /bin/true) && docker export -o "$2" "$id" && docker container rm "$id"; }

# remove dangling docker images
docker-cprune() { docker container prune --force && docker rmi "$(docker images -f 'dangling=true' -q)"; }