Skip to content

Instantly share code, notes, and snippets.

@Integralist
Last active November 3, 2021 14:23
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save Integralist/0d2f7f156aea02fce362523dd4fc185c to your computer and use it in GitHub Desktop.
Save Integralist/0d2f7f156aea02fce362523dd4fc185c to your computer and use it in GitHub Desktop.
Kali Linux Vim + Bash setup
# use VirtualBox's device menu to insert Guest Additions CDROM
# copy VBoxLinuxAdditions.run from mounted CDROM
# then eject the CDROM, run the script and then shutdown the VM
# you'll then go into VirtualBox and setup shared directories etc
cd ~ && eject /media/cdrom0
sudo chmod 755 VBoxLinuxAdditions.run
./VBoxLinuxAdditions.run
curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh -o ~/.git-prompt.sh
curl https://raw.githubusercontent.com/rcaloras/bash-preexec/master/bash-preexec.sh -o ~/.bash-preexec.sh
mkdir -p ~/.vim/{autoload,bundle,colors}
curl -LSso ~/.vim/colors/integralist.vim https://raw.githubusercontent.com/Integralist/dotfiles/master/.vim/colors/integralist.vim
curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
curl -LSso ~/.vim/plugins https://raw.githubusercontent.com/Integralist/dotfiles/master/voom/plugins
curl -LSso /usr/local/bin/voom https://raw.githubusercontent.com/airblade/voom/master/voom
chmod 744 /usr/local/bin/voom
alias voom='VIM_DIR=~/.vim voom'
sudo apt-get install neovim
ln -s ~/.vim ~/.config/nvim
ln -s ~/.vimrc ~/.config/nvim/init.vim
curl -LSso ~/googler-completion.bash https://raw.githubusercontent.com/jarun/googler/master/auto-completion/bash/googler-completion.bash
apt-get install git
git --version
add-apt-repository ppa:pgolm/the-silver-searcher
apt-get update
apt-get install silversearcher-ag
apt-get install tree
curl https://sift-tool.org/downloads/sift/sift_0.9.0_linux_amd64.tar.gz -o /tmp/sift.tar.gz
cd /tmp && tar xzf sift.tar.gz && cp sift/sift /usr/bin/sift
mkdir Developer && cd Developer/
mkdir Python{2,3} && cd Python3/
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils
curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash
pyenv install 3.5.1
pyenv local 3.5.1
pip install --upgrade pip
pip install pylint flake8 flake8-quotes pep8-naming
pip install --upgrade neovim
cd ../Python2/
pyenv install 2.7.11
pyenv local 2.7.11
pip install --upgrade pip
pip install pylint flake8 flake8-quotes pep8-naming
pip install --upgrade neovim
# copied modified files back to the host shared directory
cp ~/.bashrc /media/sf_Developer/.bashrc
cp ~/.vimrc /media/sf_Developer/.vimrc
sed -i 's/XKBMODEL="pc105"/XKBMODEL="macintosh"/' /etc/default/keyboard # pc105 was old value
reboot # needed for keyboard to take effect
#!/usr/bin/env bash
# https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh
source ~/.git-prompt.sh
# https://github.com/jarun/googler/blob/master/auto-completion/bash/googler-completion.bash
source ~/googler-completion.bash
# tells Readline to perform filename completion in a case-insensitive fashion
bind "set completion-ignore-case on"
# filename matching during completion will treat hyphens and underscores as equivalent
bind "set completion-map-case on"
# will get Readline to display all possible matches for an ambiguous pattern at the first <Tab> press instead of at the second
bind "set show-all-if-ambiguous on"
# no bell sound on error
bind "set bell-style none"
# enable emacs like bindings (<C-a> and <C-e> for start and end of line shortcuts)
set -o emacs
# append to the history file, don't overwrite it
shopt -s histappend
# save multi-line commands as one command
shopt -s cmdhist
# no need to type cd (works for .. but not -, although alias -- -='cd -' fixes it)
shopt -s autocd 2>/dev/null
# autocorrect minor spelling errors
shopt -s dirspell 2>/dev/null
shopt -s cdspell 2>/dev/null
# check windows size if windows is resized
shopt -s checkwinsize 2>/dev/null
# use extra globing features. See man bash, search extglob.
shopt -s extglob 2>/dev/null
# include .files when globbing.
shopt -s dotglob 2>/dev/null
# case insensitive globbing
shopt -s nocaseglob 2>/dev/null
# can be useful to utilise the gnu style error message format
shopt -s gnu_errfmt 2>/dev/null
# ensure SIGHUP is sent to all jobs when an interactive login shell exits
shopt -s huponexit 2>/dev/null
# custom environment variables
export GITHUB_USER="integralist"
# application configuration
export GOOGLER_COLORS=bjdxxy # https://github.com/jarun/googler/
export LSCOLORS="dxfxcxdxbxegedabagacad" # http://geoff.greer.fm/lscolors/
export MANPAGER="less -X" # Don't clear the screen after quitting a manual page
export EDITOR="vim"
# git specific configurations
export GIT_PS1_SHOWCOLORHINTS=true
export GIT_PS1_SHOWDIRTYSTATE=true # * for unstaged changes (+ staged but uncommitted changes)
export GIT_PS1_SHOWSTASHSTATE=true # $ for stashed changes
export GIT_PS1_SHOWUNTRACKEDFILES=true # % for untracked files
export GIT_PS1_SHOWUPSTREAM="auto" # > for local commits on HEAD not pushed to upstream
# < for commits on upstream not merged with HEAD
# = HEAD points to same commit as upstream
# terminal configuration
export PROMPT_COMMAND='history -a' # record each line as it gets issued
# history configuration
export HISTSIZE=500000
export HISTFILESIZE=100000
export HISTCONTROL="erasedups:ignoreboth" # avoid duplicate entries
export HISTIGNORE="&:[ ]*:exit:ls:bg:fg:history" # don't record some commands
export HISTTIMEFORMAT='%F %T ' # useful timestamp format
# force colours
export force_color_prompt=yes
# use colour prompt
export color_prompt=yes
# \033[ -> Indicates the beginning of color in the text
# x;yzm -> Indicates color code
# \033[00m -> Indicates the end of color in the text
#
# 00;30 = black
# 00;31 = red
# 00;32 = green
# 00;33 = yellow
# 00;34 = blue
# 00;35 = purple
# 00;36 = cyan
# 00;37 = grey
#
# use 01 for background colour, rather than text colour
function prompt_right() {
echo -e ""
}
function prompt_left() {
num_jobs=$(jobs | wc -l)
if [ "$num_jobs" -eq 0 ]; then
num_jobs=""
else
num_jobs=" (\j)"
fi
echo -e "\033[00;33m\u.\033[00m \w/$num_jobs\033[00;31m$(__git_ps1) \033[00m(\A)" # \A is the current time
}
function prompt() {
unset PS1
PS1=$(printf "%s \$ " "$(prompt_left)")
}
function gms() {
git merge --squash "$1"
}
function gc {
if [ -z "$1" ]; then
printf "\n\tUse: gc some-existing-branch-name\n"
else
git checkout "$1"
fi
}
function gcb {
if [ -z "$1" ]; then
printf "\n\tUse: gcb some-new-branch-name (branch will be created)\n"
else
git checkout -b "$1"
fi
}
# We use _ to indicate an unused variable
# Otherwise shellcheck will kick up a stink
# shellcheck disable=SC2034
read -r -d '' git_icons <<- EOF
* unstaged changes
+ staged but uncommitted changes
$ stashed changes
% untracked files
> local commits on HEAD not pushed to upstream
< commits on upstream not merged with HEAD
= HEAD points to same commit as upstream
EOF
# use `type <alias>` to see what is assigned to an alias/fn/builtin/keyword
alias dotfiles="ls -a | grep '^\.' | grep --invert-match '\.DS_Store\|\.$'"
alias getcommit="git log -1 | cut -d ' ' -f 2 | head -n 1"
alias sshkey="ssh-keygen -t rsa -b 4096 -C 'mark.mcdx@gmail.com'"
alias ls="ls -GpF"
alias ll="ls -laGpFHh"
alias r="source ~/.bashrc"
alias cm="git checkout master"
alias c-="git checkout -"
alias gb="git branch"
alias gbd="git branch -D"
alias gcp="git cherry-pick -"
alias gpr="git pull --rebase origin master"
alias wat='echo "$git_icons"'
alias wut='echo "$git_icons"'
alias gitupstream="echo git branch -u origin/\<branch\>"
alias drm='docker rm $(docker ps -a -q)'
alias drmi='docker rmi $(docker images -q)'
alias pipall="pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U"
alias uid='echo $(uuidgen)'
alias datesec='date +%s'
export PATH="/root/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
# https://raw.githubusercontent.com/rcaloras/bash-preexec/master/bash-preexec.sh
source ~/.bash-preexec.sh
# preexec executes just BEFORE a command is executed
# preexec() { echo "just typed $1"; }
# precmd executes just AFTER a command is executed, but before the prompt is shown
precmd() { prompt; }
# installation of vim plugins using Voom
" Use the system clipboard
set clipboard+=unnamed
" Switch syntax highlighting on
syntax on
" Don't worry about trying to support old school Vi features
set nocompatible
" Disable Mouse (this is something that only recently affected me within NeoVim)
" Seemed using the mouse to select some text would make NeoVim jump into VISUAL mode?
set mouse=
" No backup files
set nobackup
" No write backup
set nowritebackup
" No swap file
set noswapfile
" Command history
set history=100
" Always show cursor
set ruler
" Show incomplete commands
set showcmd
" Incremental searching (search as you type)
set incsearch
" Highlight search matches
set hlsearch
" Ignore case in search
set smartcase
" Make sure any searches /searchPhrase doesn't need the \c escape character
set ignorecase
" A buffer is marked as ‘hidden’ if it has unsaved changes, and it is not currently loaded in a window
" If you try and quit Vim while there are hidden buffers, you will raise an error:
" E162: No write since last change for buffer “a.txt”
set hidden
" Turn word wrap off
set nowrap
" Allow backspace to delete end of line, indent and start of line characters
set backspace=indent,eol,start
" Convert tabs to spaces
set expandtab
" Set tab size in spaces (this is for manual indenting)
set tabstop=2
" The number of spaces inserted for a tab (used for auto indenting)
set shiftwidth=2
" Turn on line numbers
set number
" Highlight tailing whitespace
set list listchars=tab:\ \ ,trail:·
" Get rid of the delay when pressing O (for example)
" http://stackoverflow.com/questions/2158516/vim-delay-before-o-opens-a-new-line
set timeout timeoutlen=1000 ttimeoutlen=100
" Always show status bar
set laststatus=2
" Set the status line to something useful
set statusline=%f\ %m\ %=L:%l/%L\ C:%c\ (%p%%)
" UTF encoding
set encoding=utf-8
" Autoload files that have changed outside of vim
set autoread
" Better splits (new windows appear below and to the right)
set splitbelow
set splitright
" Highlight the current line
set cursorline
" Ensure Vim doesn't beep at you every time you make a mistype
set visualbell
" Visual autocomplete for command menu (e.g. :e ~/path/to/file)
set wildmenu
" Redraw only when we need to (i.e. don't redraw when executing a macro)
set lazyredraw
" Highlight a matching [{()}] when cursor is placed on start/end character
set showmatch
" <C-x><C-k> for word autocomplete
set dictionary=/usr/share/dict/words
" Use Ag for :grep command (would use Sift but it doesn't work well)
set grepprg=ag\ --nogroup\ --nocolor
" Set built-in file system explorer to use layout similar to the NERDTree plugin
" P opens file in previously focused window
" o opens file in new horizontal split window
" v opens file in new vertical split window
" t opens file in new tab split window
let g:netrw_liststyle=3
execute pathogen#infect()
filetype plugin indent on
let g:default_theme="gruvbox"
set background=dark
execute 'colorscheme ' . g:default_theme
" http://pep8.readthedocs.io/en/latest/intro.html#error-codes
" https://github.com/PyCQA/pep8-naming
let g:neomake_python_flake8_args = neomake#makers#ft#python#flake8()['args'] + ['--ignore', 'N802']
" http://pylint-messages.wikidot.com/all-codes
" http://pylint-messages.wikidot.com/all-messages
let g:neomake_python_pylint_args = neomake#makers#ft#python#pylint()['args'] + ['-d', 'missing-docstring,invalid-name']
" Enable both default Python linters
let g:neomake_python_enabled_makers = ['flake8', 'pylint']
" https://github.com/koalaman/shellcheck/wiki/SC1091
let g:neomake_sh_shellcheck_args = neomake#makers#ft#sh#shellcheck()['args'] + ['-e', 'SC1090,SC1091']
let g:neomake_bash_enabled_makers = ['shellcheck']
" General Neomake configuration
let g:neomake_open_list=2
let g:neomake_list_height=5
let g:neomake_verbose=3
" Run Neomake whenever we enter or write a buffer
autocmd BufWritePost,BufWinEnter * silent Neomake
" The following configuration is useful if you don't like
" the icons (which are provided by default) for highlighting errors/warnings
"
" let g:neomake_warning_sign = {
" \ 'text': 'W',
" \ 'texthl': 'WarningMsg',
" \ }
" let g:neomake_error_sign = {
" \ 'text': 'E',
" \ 'texthl': 'ErrorMsg',
" \ }
" vim-go
let g:go_fmt_command = "goimports"
let g:go_metalinter_autosave = 1
let g:go_metalinter_autosave_enabled = ['vet', 'golint']
let g:go_metalinter_enabled = ['vet', 'golint', 'errcheck']
" tabular
map <Leader>e :Tabularize /=<CR>
map <Leader>c :Tabularize /:<CR>
map <Leader>es :Tabularize /=\zs<CR>
map <Leader>cs :Tabularize /:\zs<CR>
" ctrlp
map <leader>t <C-p>
map <leader>y :CtrlPBuffer<CR>
let g:ctrlp_show_hidden=1
let g:ctrlp_working_path_mode=0
let g:ctrlp_max_height=30
let g:ctrlp_arg_map = 1 " Override <C-o> to provide options for how to open files
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*.,*/.DS_Store " Files matched are ignored when expanding wildcards
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""' " Use Ag for searching instead of VimScript (might not work with ctrlp_show_hidden and ctrlp_custom_ignore)
let g:ctrlp_custom_ignore = '\v[\/]((node_modules)|\.(git|svn|grunt|sass-cache))$' " Directories to ignore when fuzzy finding
" ack
let g:ackprg = 'ag --nogroup --nocolor --column'
" vim-textobj-rubyblock
runtime macros/matchit.vim
" vim-commentary
xmap <leader><leader><leader> <Plug>Commentary
nmap <leader><leader><leader> <Plug>Commentary
omap <leader><leader><leader> <Plug>Commentary
nmap <leader><leader><leader> <Plug>CommentaryLine
" gist
let g:github_user = $GITHUB_USER
let g:gist_detect_filetype = 1
let g:gist_open_browser_after_post = 1
" camelcase
map <silent> w <Plug>CamelCaseMotion_w
map <silent> b <Plug>CamelCaseMotion_b
map <silent> e <Plug>CamelCaseMotion_e
sunmap w
sunmap b
sunmap e
" nofrils
let g:nofrils_strbackgrounds=1 " enable highlighting of strings and mispellings
" NeoVim shortcut for quick terminal exit
:silent! tnoremap <Esc> <C-\><C-n>
fun! StripTrailingWhitespace()
" Don't strip on these filetypes
if &ft =~ 'markdown'
return
endif
%s/\s\+$//e
endfun
autocmd BufWritePre * call StripTrailingWhitespace()
autocmd FileType gitcommit setlocal spell textwidth=72
autocmd FileType markdown setlocal wrap linebreak nolist textwidth=0 wrapmargin=0 " http://vim.wikia.com/wiki/Word_wrap_without_line_breaks
autocmd FileType sh,cucumber,ruby,yaml,zsh,vim setlocal shiftwidth=2 tabstop=2 expandtab
autocmd FileType php,python setlocal shiftwidth=4 tabstop=4 expandtab
" See `:h fo-table` for details of formatoptions `t` to force wrapping of text
autocmd FileType python,ruby,go,sh,javascript setlocal textwidth=79 formatoptions+=t
" Set different colorscheme for Bash and VimL scripts
autocmd BufEnter *.sh,*.vimrc,*.txt colorscheme github
autocmd BufLeave *.sh,*.vimrc,*.txt execute 'set background=dark' | execute 'colorscheme ' . g:default_theme
" Specify syntax highlighting for specific files
autocmd Bufread,BufNewFile *.spv set filetype=php
autocmd Bufread,BufNewFile *.md set filetype=markdown " Vim interprets .md as 'modula2' otherwise, see :set filetype?
" Run Goyo plugin on Markdown files for when I'm writing blog posts
autocmd Bufread,BufEnter *.md,*.txt execute 'normal zR' | execute 'Goyo'
autocmd BufLeave *.md,*.txt execute 'Goyo!'
" Automatically reload vimrc when it's saved
" autocmd BufWritePost .vimrc so ~/.vimrc
" Rainbow parenthesis always on!
autocmd VimEnter * if exists(':RainbowParenthesesToggle') | exe ":RainbowParenthesesToggleAll" | endif
" Change colourscheme when diffing
fun! SetDiffColours()
highlight DiffAdd cterm=bold ctermfg=white ctermbg=DarkGreen
highlight DiffDelete cterm=bold ctermfg=white ctermbg=DarkGrey
highlight DiffChange cterm=bold ctermfg=white ctermbg=DarkBlue
highlight DiffText cterm=bold ctermfg=white ctermbg=DarkRed
endfun
autocmd FilterWritePre * call SetDiffColours()
" Map § key to :nohlsearch (or :noh for short)
map § :nohlsearch<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment