dotfiles

personal configuration files and scripts
git clone https://tongong.net/git/dotfiles.git
Log | Files | Refs | README

bashrc (2542B)


      1 # If not running interactively, don't do anything
      2 [[ $- != *i* ]] && return
      3 
      4 # colors in framebuffer
      5 # https://askubuntu.com/a/153493
      6 if [ "$TERM" = "linux" ]; then
      7 	# 8 normal colors
      8 	echo -en "\e]P0242424",  # black
      9 	echo -en "\e]P1d25252",  # red
     10 	echo -en "\e]P2a4c161",  # green
     11 	echo -en "\e]P3ffc56d",  # yellow
     12 	echo -en "\e]P46c99ba",  # blue
     13 	echo -en "\e]P5d096d9",  # magenta
     14 	echo -en "\e]P6bdd6ff",  # cyan
     15 	echo -en "\e]P7ffffff",  # white
     16 
     17 	# 8 bright colors
     18 	echo -en "\e]P8535353",  # black
     19 	echo -en "\e]P9f00c0c",  # red
     20 	echo -en "\e]PAc1df74",  # green
     21 	echo -en "\e]PBe1e48a",  # yellow
     22 	echo -en "\e]PC8ab6d9",  # blue
     23 	echo -en "\e]PDefb5f7",  # magenta
     24 	echo -en "\e]PEdbf4ff",  # cyan
     25 	echo -en "\e]PFffffff",  # white
     26     clear # for background artifacting
     27 fi
     28 
     29 # add colors where possible
     30 alias ls='exa -l'
     31 alias grep='grep --color=auto'
     32 alias diff='diff --color=auto'
     33 function man() {
     34     LESS_TERMCAP_md=$'\e[01;31m' \
     35     LESS_TERMCAP_me=$'\e[0m' \
     36     LESS_TERMCAP_se=$'\e[0m' \
     37     LESS_TERMCAP_ue=$'\e[0m' \
     38     LESS_TERMCAP_us=$'\e[01;32m' \
     39     command man "$@"
     40 }
     41 
     42 # don't put duplicate lines or lines starting with space in the history
     43 HISTCONTROL=ignoreboth
     44 # append to the history file, don't overwrite it
     45 shopt -s histappend
     46 # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
     47 HISTSIZE=1000
     48 HISTFILESIZE=2000
     49 
     50 # shell promt
     51 PS1='\[\e[01;92m\]\w \[\e[01;34m\]\$ \[\e[00m\]'
     52 
     53 # Directoy up alias
     54 alias ..='cd ..'
     55 alias ...='cd ../..'
     56 alias ....='cd ../../..'
     57 alias .....='cd ../../../..'
     58 
     59 # nvim alias
     60 alias v='nvim'
     61 
     62 # cheat.sh shortcut
     63 function cheat(){ curl cheat.sh/"$1"; }
     64 
     65 # neovim vim tutor
     66 alias vimtutor='nvim -c :Tutor'
     67 
     68 # access fugitive
     69 # kind of hacky to open vim-fugitive in a new window and than close the old one
     70 # but I do not know of a better way
     71 alias gg='nvim -c ":G" -c ":wincmd j" -c ":q"'
     72 
     73 # print the source of executables. Useful for shell scripts
     74 excat() {
     75     cat "$(which "$1")"
     76 }
     77 
     78 alias drag='dragon-drag-and-drop --and-exit'
     79 function drop() {
     80     uri="$(dragon-drag-and-drop --target --and-exit)"
     81     if [[ "$uri" == "file://"* ]];
     82     then
     83         # filenames are not allowed to be longer than 999999
     84         # i don't know how to make a substring expansion till the end
     85         uri=${uri:7:999999}
     86         sel="$(echo -e "copy\nmove" | dmenu -l 10)"
     87         [[ "$sel" == copy ]] && cp "$uri" .
     88         [[ "$sel" == move ]] && mv "$uri" .
     89     else
     90         echo "$uri"
     91     fi
     92 }
     93 
     94 # enable fcd to change working directory
     95 # see scripts/fcd
     96 alias fcd=". fcd"