Skip to content

Instantly share code, notes, and snippets.

@draeath
Last active March 2, 2022 20:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save draeath/99ebf093980cca06eec3c8bf1c4df64f to your computer and use it in GitHub Desktop.
Save draeath/99ebf093980cca06eec3c8bf1c4df64f to your computer and use it in GitHub Desktop.
environment: homedir
# keep contents in sync with .profile (except the .bashrc call)
export CONDA_DIR="/opt/${USER}/mamba"
export PATH="${CONDA_DIR}/bin:$PATH"
export CONFIGURE_OPTS="--enable-optimizations"
export PYTHON_CFLAGS="-pipe -m64 -march=generic64 -mtune=native"
export PYTHON_MAKE_OPTS="-j$(nproc)"
export PYTHON_MAKE_INSTALL_OPTS="$PYTHON_MAKE_OPTS"
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init --path)"
export RUBY_CFLAGS="-pipe -m64 -march=generic64 -mtune=native"
export RUBY_MAKE_OPTS="-j$(nproc)"
export RUBY_MAKE_INSTALL_OPTS="$PYTHON_MAKE_OPTS"
export PATH="$HOME/.rbenv/bin:$PATH"
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# deduplicate PATH
# https://unix.stackexchange.com/a/149054
if [ -x /usr/bin/perl ]; then
PATH_DEDUPLICATED="$(/usr/bin/perl -e 'print join(":", grep { not $seen{$_}++ } split(/:/, $ENV{PATH}))')"
export PATH="$PATH_DEDUPLICATED"
unset PATH_DEDUPLICATED
fi
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]]
then
PATH="$HOME/.local/bin:$HOME/bin:$PATH"
fi
if ! [[ "$PATH" =~ "$HOME/go/bin" ]]
then
PATH="$HOME/go/bin:$PATH"
fi
export PATH
if [[ $(type -P pyenv) ]] && [[ $(type -t pyenv) != function ]]; then
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
fi
if [[ $(type -P rbenv) ]] && [[ $(type -t rbenv) != function ]]; then
eval "$(rbenv init -)"
fi
# deduplicate PATH
# https://unix.stackexchange.com/a/149054
if [ -x /usr/bin/perl ]; then
PATH_DEDUPLICATED="$(/usr/bin/perl -e 'print join(":", grep { not $seen{$_}++ } split(/:/, $ENV{PATH}))')"
export PATH="$PATH_DEDUPLICATED"
unset PATH_DEDUPLICATED
fi
# custom bash completions
if [[ -f "/usr/share/bash-completion/bash_completion" ]]; then
if [[ -x "$HOME/.local/bin/aws" && -x "$HOME/.local/bin/aws_completer" ]]; then
complete -C "$HOME/.local/bin/aws_completer" aws
fi
if [[ -x "$HOME/.local/bin/kubectl" ]]; then
source <("$HOME/.local/bin/kubectl" completion bash)
fi
if [[ -x "$HOME/.local/bin/helm" ]]; then
source <("$HOME/.local/bin/helm" completion bash)
fi
if [[ -x "/usr/bin/terraform" ]]; then
complete -C /usr/bin/terraform terraform
fi
fi
if [ -f ${CONDA_DIR}/etc/profile.d/conda.sh ]; then
. ${CONDA_DIR}/etc/profile.d/conda.sh
fi
# Example colordiffrc file for dark backgrounds
#
# Set banner=no to suppress authorship info at top of
# colordiff output
banner=no
# By default, when colordiff output is being redirected
# to a file, it detects this and does not colour-highlight
# To make the patch file *include* colours, change the option
# below to 'yes'
color_patches=no
# Sometimes it can be useful to specify which diff command to
# use: that can be specified here
diff_cmd=diff
#
# available colours are: white, yellow, green, blue,
# cyan, red, magenta, black,
# darkwhite, darkyellow, darkgreen,
# darkblue, darkcyan, darkred,
# darkmagenta, darkblack
#
# Can also specify 'none', 'normal' or 'off' which are all
# aliases for the same thing, namely "don't colour highlight
# this, use the default output colour"
#
plain=darkwhite
newtext=blue
oldtext=red
diffstuff=magenta
cvsstuff=darkyellow
# keep contents in sync with .bash_profile
export CONDA_DIR="/opt/${USER}/mamba"
export PATH="${CONDA_DIR}/bin:$PATH"
export CONFIGURE_OPTS="--enable-optimizations"
export PYTHON_CFLAGS="-pipe -m64 -march=generic64 -mtune=native"
export PYTHON_MAKE_OPTS="-j$(nproc)"
export PYTHON_MAKE_INSTALL_OPTS="$PYTHON_MAKE_OPTS"
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init --path)"
export RUBY_CFLAGS="-pipe -m64 -march=generic64 -mtune=native"
export RUBY_MAKE_OPTS="-j$(nproc)"
export RUBY_MAKE_INSTALL_OPTS="$PYTHON_MAKE_OPTS"
export PATH="$HOME/.rbenv/bin:$PATH"
# deduplicate PATH
# https://unix.stackexchange.com/a/149054
if [ -x /usr/bin/perl ]; then
PATH_DEDUPLICATED="$(/usr/bin/perl -e 'print join(":", grep { not $seen{$_}++ } split(/:/, $ENV{PATH}))')"
export PATH="$PATH_DEDUPLICATED"
unset PATH_DEDUPLICATED
fi
if v:lang =~ "utf8$" || v:lang =~ "UTF-8$"
set fileencodings=ucs-bom,utf-8,latin1
endif
set nocompatible " Use Vim defaults (much better!)
set bs=indent,eol,start " allow backspacing over everything in insert mode
set ai " always set autoindenting on
set nobackup " stop littering!
set viminfo='20,\"50 " read/write a .viminfo file, don't store more than 50 lines of registers
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
"set background=dark " honestly who uses light background terminals!?
set nowrap " word wrapping is the devil
set smartcase " does what it says on the tin
set wildmenu " completions in status line
set visualbell " flash instead of making noise
set number " line numbers yay
set nofoldenable " code folding is for IDEs, knock it off
set mouse= " no mouse support, please
" put swap files etc somewhere other than current dir
set directory^=$XDG_RUNTIME_DIR//
" google does 2 s/t for all except 4 s/t for python (for some reason)
filetype plugin indent on
set shiftwidth=2
set tabstop=2
set softtabstop=2
set expandtab
au FileType python setlocal shiftwidth=4 tabstop=4 softtabstop=4
" allow F3 to toggle line number display
noremap <F3> :set invnumber<CR>
inoremap <F3> <C-O>:set invnumber<CR>
" Switch syntax highlighting on, when the terminal has colors
" adjust the line number color, and also switch on search
" pattern hilighting
if &t_Co > 2 || has("gui_running")
syntax on
highlight LineNr term=bold cterm=NONE ctermfg=DarkRed ctermbg=NONE gui=NONE guifg=DarkRed guibg=NONE
set hlsearch
endif
" .sc is a scala file, please to be hilight
au BufNewFile,BufRead *.sc set filetype=scala
if &term=="xterm"
set t_Co=8
set t_Sb=m
set t_Sf=m
endif
" Don't wake up system with blinking cursor:
let &guicursor = &guicursor . ",a:blinkon0"
" hex support
nnoremap <C-X> :Hexmode<CR>
inoremap <C-X> <Esc>:Hexmode<CR>
vnoremap <C-X> :<C-U>Hexmode<CR>
command -bar Hexmode call ToggleHex()
function ToggleHex()
" hex mode should be considered a read-only operation
" save values for modified and read-only for restoration later,
" and clear the read-only flag for now
let l:modified=&mod
let l:oldreadonly=&readonly
let &readonly=0
let l:oldmodifiable=&modifiable
let &modifiable=1
if !exists("b:editHex") || !b:editHex
" save old options
let b:oldft=&ft
let b:oldbin=&bin
" set new options
setlocal binary " make sure it overrides any textwidth, etc.
silent :e " this will reload the file without trickeries
"(DOS line endings will be shown entirely )
let &ft="xxd"
" set status
let b:editHex=1
" switch to hex editor
%!xxd -g 1
else
" restore old options
let &ft=b:oldft
if !b:oldbin
setlocal nobinary
endif
" set status
let b:editHex=0
" return to normal editing
%!xxd -r
endif
" restore values for modified and read only state
let &mod=l:modified
let &readonly=l:oldreadonly
let &modifiable=l:oldmodifiable
endfunction
" vim-plug stuff
" see: https://github.com/junegunn/vim-plug
" Make sure you use single quotes
" installation:
" curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
call plug#begin('~/.vim/plugged')
Plug 'pearofducks/ansible-vim'
Plug 'hashivim/vim-terraform'
Plug 'snakemake/snakemake', {'rtp': 'misc/vim'}
call plug#end()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment