Skip to content

Instantly share code, notes, and snippets.

@abrodkin
Last active November 28, 2021 19:49
Show Gist options
  • Save abrodkin/0771b1cc2ce42651a63f0537666b92dd to your computer and use it in GitHub Desktop.
Save abrodkin/0771b1cc2ce42651a63f0537666b92dd to your computer and use it in GitHub Desktop.
My dotfiles

.bashrc

# Figure-out location of Python user packages
PYTHON_SITE=$(python -m site --user-site)

# Powerline configuration
if [ -f $PYTHON_SITE/powerline/bindings/bash/powerline.sh ]; then
    $HOME/.local/bin/powerline-daemon -q
    POWERLINE_BASH_CONTINUATION=1
    POWERLINE_BASH_SELECT=1
    source $PYTHON_SITE/powerline/bindings/bash/powerline.sh
fi

################################################################################
# Fix console size, see https://unix.stackexchange.com/a/61608
################################################################################
shopt -s checkwinsize

################################################################################
#»      History management
################################################################################
# Configure history management:
# - ignore duplicates
# - ignore lines starting with a space
# - keep longer history
# - append when writing (don't lose history of other terminal tabs)
# - save history after every command
# Note to self: use 'history -n' to get the history from other terminal
# tabs.
# Source: http://briancarper.net/blog/248/

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

# append to the history file, don't overwrite it
# (otherwise we would lose history of other xterms)
shopt -s histappend

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=50000
HISTFILESIZE=50000
# note: big ~/.bash_history costs in startup time
# (stupid readline O(N**2) "append to end of singly-linked list" algorithm)

# Save the history after every command
# (note: PROMPT_COMMAND is overwritten by bashrc.title)
#PROMPT_COMMAND='history -a'
PROMPT_COMMAND="history -n; history -w; history -c; history -r; $PROMPT_COMMAND"

# remove duplicates while preserving input order
function dedup {
   awk '! x[$0]++' $@
}

# removes $HISTIGNORE commands from input
function remove_histignore {
   if [ -n "$HISTIGNORE" ]; then
      # replace : with |, then * with .*
      local IGNORE_PAT=`echo "$HISTIGNORE" | sed s/\:/\|/g | sed s/\*/\.\*/g`
      # negated grep removes matches
      grep -vx "$IGNORE_PAT" $@
   else
      cat $@
   fi
}

# clean up the history file by remove duplicates and commands matching
# $HISTIGNORE entries
function history_cleanup {
   local HISTFILE_SRC=~/.bash_history
   local HISTFILE_DST=/tmp/.$USER.bash_history.clean
   if [ -f $HISTFILE_SRC ]; then
      \cp $HISTFILE_SRC $HISTFILE_SRC.backup
      dedup $HISTFILE_SRC | remove_histignore >| $HISTFILE_DST
      \mv $HISTFILE_DST $HISTFILE_SRC
      chmod go-r $HISTFILE_SRC
      history -c
      history -r
   fi
}

.vimrc

" Syntax highliting
syntax enable

" COLOR THEMING
" Dark flavor
set background=dark

" Fancy teminal's 24-bit color!
if (has("termguicolors"))
  set termguicolors
endif

" Theme selection
colorscheme solarized8

" POWERLINE
set rtp+=~/.local/lib/python3.8/site-packages/powerline/bindings/vim
" By default, the statusline (and therefore Powerline) only appears when
" there are multiple windows open. To show it all the time, use:
set laststatus=2

.tmux.conf

source ~/.local/lib/python3.8/site-packages/powerline/bindings/tmux/powerline.conf

# Mouse support - set to on if you want to use the mouse
set -g mouse on

# Enable activity alerts
setw -g monitor-activity on
set -g visual-activity on
set -g bell-action any

# Set new history limit
set -g history-limit 100000

# Use VI-style key bindings
set-window-option -g mode-keys vi

# split panes using | and -
bind | split-window -h
bind - split-window -v
unbind '"'
unbind %

# reload config file
bind r source-file ~/.tmux.conf

# swith panes using Alt-arrow without prefix
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D

# Move tabs left & right with Shift-Left/Right without prefix
bind -n S-Left swap-window -t -1
bind -n S-Right swap-window -t +1

# Enable true colors (24-bit)
set -g default-terminal "xterm-256color"
set -ga terminal-overrides ",*256col*:Tc"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment