diff options
Diffstat (limited to '.bashrc')
-rw-r--r-- | .bashrc | 102 |
1 files changed, 53 insertions, 49 deletions
@@ -1,54 +1,57 @@ -#!/bin/bash +#!/bin/bash -eu # source exports -export BASH_PROFILE=1 && . "$HOME/.bash_profile"; +export BASH_PROFILE=1 && . "$HOME/.bash_profile" # bail if not interactive -echo $- | grep -q "i" || return; +printf '%s' "$-" | grep -q "i" || return # cd using directory name -shopt -s autocd; +shopt -s autocd # append bash history entries -shopt -s histappend; +shopt -s histappend # bash history one command per line -shopt -s cmdhist; +shopt -s cmdhist + +# disable program completion +shopt -u progcomp # enable vi mode -set -o vi; +set -o vi # disable ctrl+s -stty stop ''; -stty start ''; -stty -ixon; -stty -ixoff; +stty stop '' +stty start '' +stty -ixon +stty -ixoff # fzf bindings -fzfcompletion=$(readlink "$(type -P fzf)" | cut -d '/' -f -4)/share/fzf/completion.bash; -fzfkeybindings=$(readlink "$(type -P fzf)" | cut -d '/' -f -4)/share/fzf/key-bindings.bash; -[ -f "$fzfcompletion" ] && . "$fzfcompletion"; -[ -f "$fzfkeybindings" ] && . "$fzfkeybindings"; +fzfcompletion="$HOME/.config/fzf/completion.bash" +fzfkeybindings="$HOME/.config/fzf/key-bindings.bash" +[ -f "$fzfcompletion" ] && . "$fzfcompletion" +[ -f "$fzfkeybindings" ] && . "$fzfkeybindings" # 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 + 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 @@ -76,9 +79,8 @@ alias chmod='chmod --preserve-root' alias chgrp='chgrp --preserve-root' # general aliases -alias alsamixer='alsamixer -V all' +alias alsamixer='alsamixer --view all' alias archey3="archey3 --config=~/.config/archey3.cfg" -alias audacity='PULSE_LATENCY_MSEC=30 audacity' alias colortest='msgcat --color=test' alias dash='PS1="$ " dash' alias diceware='diceware -d " "' @@ -89,10 +91,9 @@ alias grep='grep --color=tty -d skip' alias locate='locate -ie' alias ls='ls -hN --color=always --group-directories-first' alias lsblk='lsblk -o NAME,MAJ:MIN,RM,SIZE,FSTYPE,RO,TYPE,MOUNTPOINT,MODEL' -alias lxc-attach='lxc-attach --clear-env -n' -alias lxc-ls='lxc-ls -f' +alias lxc-attach='lxc-attach --clear-env --name' +alias lxc-ls='lxc-ls --fancy' alias lynx='lynx -cfg ~/.config/lynx/lynx.cfg' -alias mocp='mocp -M $XDG_CONFIG_HOME/moc' alias newsboat='newsboat -c $XDG_CONFIG_HOME/newsboat/cache.db -u $XDG_CONFIG_HOME/newsboat/urls -C $XDG_CONFIG_HOME/newsboat/config' alias nix-index='nix-index --db $XDG_DATA_HOME/nix-index' alias nix-locate='nix-locate --db $XDG_DATA_HOME/nix-index' @@ -103,27 +104,30 @@ alias tidy='tidy -config $HOME/.config/tidy.conf' alias units='units --history "$XDG_CACHE_HOME"/units_history' # nix helpers -nix-which() { readlink "$(type -P "$1")"; } +nix-which() { readlink --canonicalize "$(type -P "$1")"; } # lxc helpers -lxc-copy() { A=$1 && B=$2 && shift 2 && $(type -P lxc-copy) -an "$A" -N "$B" "$@"; } -lxc-restart() { $(type -P lxc-stop) -kn "$1"; $(type -P lxc-start) -n "$1"; } -lxc-start() { for container in "$@"; do $(type -P lxc-start) -n "$container"; done } -lxc-stop() { for container in "$@"; do $(type -P lxc-stop) -kn "$container"; done } -lxc-destroy() { for container in "$@"; do $(type -P lxc-destroy) -n "$container"; done } +lxc-copy() { A=$1 && B=$2 && shift 2 && $(type -P lxc-copy) --allowrunning --name "$A" -N "$B" "$@"; } +lxc-shell() { lxc-start "$1" > /dev/null 2>&1 && lxc-attach "$1" -- /bin/sh -c 'export HOME="/root" && . /etc/profile && /bin/sh'; } +lxc-restart() { $(type -P lxc-stop) --kill --name "$1"; $(type -P lxc-start) -n "$1"; } +lxc-start() { for container in "$@"; do $(type -P lxc-start) --name "$container"; done } +lxc-stop() { for container in "$@"; do $(type -P lxc-stop) --kill --name "$container"; done } +lxc-destroy() { for container in "$@"; do $(type -P lxc-destroy) --name "$container"; done } # source fzf markers [ -f "$HOME/.config/fzf/marks.plugin.bash" ] && . "$HOME/.config/fzf/marks.plugin.bash" -# remove bash history duplicates -history-remove-duplicates() { awk '!visited[$0]++' "$HOME/.bash_history" | sponge "$HOME/.bash_history"; } - # extract docker container as rootfs -docker-rootfs() { id=$(docker run -d "$1" /bin/true) && docker export "$id" -o "$2.tar" && docker container rm "$id"; } +docker-rootfs() { id=$(docker run --detach "$1" /bin/true) \ + && docker export "$id" --output "rootfs.tar" \ + && docker container rm "$id" \ + && ls -l rootfs.tar; } -# https://til.simonwillison.net/bash/escaping-a-string -# press ctrl+d after writing string to standard input +# press ctrl+d after writing string to standard input (https://til.simonwillison.net/bash/escaping-a-string) shellquote() { printf '%q\n' "$(cat)"; } +# show window title of last command (https://stackoverflow.com/a/5080670) +trap 'echo -ne "\033]2;term: $PWD $(history 1 | tr -s " " | cut -d " " -f 5-)\007"' DEBUG + # swallow swallow() { "$@" & disown; exit; } |