Thedro's Dotfiles https://www.thedroneely.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

126 lines
4.0KB

  1. #!/bin/bash
  2. # source exports
  3. export BASH_PROFILE=loaded && . "$HOME/.bash_profile";
  4. # bail if not interactive
  5. echo $- | grep -q "i" || return;
  6. # cd using directory name
  7. shopt -s autocd;
  8. # append bash history entries
  9. shopt -s histappend;
  10. # bash history one command per line
  11. shopt -s cmdhist;
  12. # enable vi mode
  13. set -o vi;
  14. # disable ctrl+s
  15. stty stop '';
  16. stty start '';
  17. stty -ixon;
  18. stty -ixoff;
  19. # fzf bindings
  20. fzfcompletion=$(readlink "$(type -P fzf)" | cut -d '/' -f -4)/share/fzf/completion.bash;
  21. fzfkeybindings=$(readlink "$(type -P fzf)" | cut -d '/' -f -4)/share/fzf/key-bindings.bash;
  22. [ -f "$fzfcompletion" ] && . "$fzfcompletion";
  23. [ -f "$fzfkeybindings" ] && . "$fzfkeybindings";
  24. # set virtual console colors
  25. if [ "$TERM" = "linux" ]; then
  26. echo -en "\e]P0111111" #black [background]
  27. echo -en "\e]P1D84F4F" #darkred
  28. echo -en "\e]P2DEFF3E" #darkgreen
  29. echo -en "\e]P3FFDF23" #brown
  30. echo -en "\e]P479AEFF" #darkblue
  31. echo -en "\e]P58894CF" #darkmagenta
  32. echo -en "\e]P679AEFF" #darkcyan
  33. echo -en "\e]P7dddddd" #lightgray
  34. echo -en "\e]P8DDDDDD" #darkgray
  35. echo -en "\e]P9E84F4F" #red
  36. echo -en "\e]PABEFF3E" #green
  37. echo -en "\e]PBFEA63C" #yellow
  38. echo -en "\e]PC69AEFF" #blue
  39. echo -en "\e]PD9894CF" #magenta
  40. echo -en "\e]PE69AEFF" #cyan
  41. echo -en "\e]PFffffff" #white [foreground]
  42. clear #for background artifacting
  43. fi
  44. # color man
  45. man() {
  46. env LESS_TERMCAP_mb="$(printf "\e[1;31m")" \
  47. LESS_TERMCAP_md="$(printf "\e[1;31m")" \
  48. LESS_TERMCAP_me="$(printf "\e[0m")" \
  49. LESS_TERMCAP_se="$(printf "\e[0m")" \
  50. LESS_TERMCAP_so="$(printf "\e[1;44;33m")" \
  51. LESS_TERMCAP_ue="$(printf "\e[0m")" \
  52. LESS_TERMCAP_us="$(printf "\e[1;32m")" \
  53. man "$@"
  54. }
  55. # ssh agent with keychain
  56. alias ssh='eval $(keychain --dir $HOME/.cache/keychain --eval --agents ssh -Q --quiet ~/.ssh/mobile ~/.ssh/primary) && ssh'
  57. # parenting
  58. alias mv='mv -i'
  59. alias cp='cp -i'
  60. alias ln='ln -i'
  61. alias rm='rm -I --preserve-root'
  62. alias chown='chown --preserve-root'
  63. alias chmod='chmod --preserve-root'
  64. alias chgrp='chgrp --preserve-root'
  65. # general aliases
  66. alias alsamixer='alsamixer -V all'
  67. alias archey3="archey3 --config=~/.config/archey3.cfg"
  68. alias audacity='PULSE_LATENCY_MSEC=30 audacity'
  69. alias colortest='msgcat --color=test'
  70. alias dash='PS1="$ " dash'
  71. alias diceware='diceware -d " "'
  72. alias dict='dict -h localhost'
  73. alias dmesg='dmesg -e'
  74. alias emacs='TERM=xterm-256color emacs -nw --load ~/.config/emacs/emacs.el'
  75. alias go='GOPATH=$(pwd)/go go'
  76. alias grep='grep --color=tty -d skip'
  77. alias locate='locate -ie'
  78. alias ls='ls -hN --color=always --group-directories-first'
  79. alias lsblk='lsblk -o NAME,MAJ:MIN,RM,SIZE,FSTYPE,RO,TYPE,MOUNTPOINT,MODEL'
  80. alias lxc-attach='lxc-attach --clear-env -n'
  81. alias lxc-ls='lxc-ls -f'
  82. alias mocp='mocp -M $XDG_CONFIG_HOME/moc'
  83. alias newsboat='newsboat -c $XDG_CONFIG_HOME/newsboat/cache.db -u $XDG_CONFIG_HOME/newsboat/urls -C $XDG_CONFIG_HOME/newsboat/config'
  84. alias pacman='sudo pacman'
  85. alias rangerinf='while true; do ranger; done'
  86. alias rofi='rofi -cache-dir $XDG_DATA_HOME'
  87. alias sh='dash'
  88. alias tidy='tidy -config $HOME/.config/tidy.conf'
  89. alias wavemon='sudo wavemon'
  90. alias wget='wget --hsts-file $HOME/.cache/wget.history'
  91. # nix helpers
  92. nix-which() { readlink "$(type -P "$1")"; }
  93. # lxc helpers
  94. lxc-copy() { A=$1 && B=$2 && shift 2 && $(type -P lxc-copy) -an "$A" -N "$B" "$@"; }
  95. lxc-restart() { $(type -P lxc-stop) -kn "$1"; $(type -P lxc-start) -n "$1"; }
  96. lxc-start() { for container in "$@"; do $(type -P lxc-start) -n "$container"; done }
  97. lxc-stop() { for container in "$@"; do $(type -P lxc-stop) -kn "$container"; done }
  98. lxc-destroy() { for container in "$@"; do $(type -P lxc-destroy) -n "$container"; done }
  99. # source fzm
  100. [ -f "$HOME/.config/fzf-marks/fzf-marks.plugin.bash" ] && . "$HOME/.config/fzf-marks/fzf-marks.plugin.bash"
  101. # remove bash history duplicates
  102. history-remove-duplicates() { awk '!visited[$0]++' "$HOME/.bash_history" | sponge "$HOME/.bash_history"; }
  103. # extract docker container as rootfs
  104. docker-rootfs() { id=$(docker run -d "$1" /bin/true) && docker export "$id" -o "$2.tar" && docker container rm "$id"; }
  105. # swallow
  106. swallow() { "$@" & disown; exit; }