Skip to content

Instantly share code, notes, and snippets.

@luizomf
Last active May 22, 2026 19:21
Show Gist options
  • Select an option

  • Save luizomf/9a52ba5b7b43aa69cc9a7121795bb9fa to your computer and use it in GitHub Desktop.

Select an option

Save luizomf/9a52ba5b7b43aa69cc9a7121795bb9fa to your computer and use it in GitHub Desktop.
Simple bash config to append to .bashrc for servers. (Configure vim and bash vim mode - opinionated). - .vimrc .bashrc
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fi
syntax on
set nocompatible
"set number
"set relativenumber
set nocursorline
"set colorcolumn=80
set backupcopy=yes
set expandtab
set tabstop=2
set shiftwidth=2
set expandtab
"set autoindent
"set smartindent
set noautoindent
set nosmartindent
set mouse=""
set clipboard=unnamed
set nowrap
set backspace=indent,eol,start
set formatoptions-=t
set nostartofline
set ruler
set showmatch
set showmode
set showcmd
set textwidth=80
" set title
set hlsearch
set incsearch
set notermguicolors
set t_Co=256
" colorscheme habamax " Nice
" colorscheme sorbet " Nice
" colorscheme lunaperche " Nice
" colorscheme pablo " Nice
colorscheme slate " Nice
" colorscheme wildcharm " Nice
" colorscheme zaibatsu " Nice
set background=dark
highlight Normal ctermbg=NONE guibg=NONE
highlight NonText ctermbg=NONE guibg=NONE
highlight EndOfBuffer ctermbg=NONE guibg=NONE
highlight LineNr ctermbg=NONE guibg=NONE
highlight SignColumn ctermbg=NONE guibg=NONE
highlight RedundantWhitespace ctermbg=blue guibg=blue
match RedundantWhitespace /\s\+$\| \+\ze\t/
" ### Opens the file in the same position where I left it
autocmd BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
" ### KEYMAPS
let mapleader = " "
" INSERT
inoremap jj <Esc>
" NORMAL (MISC)
nnoremap <leader>ff :Files<CR>
nnoremap <leader>w :w<CR>
nnoremap <leader>h :noh<CR>
" NORMAL (BUFFERS)
nnoremap <leader><Tab> <C-^><CR>
nnoremap <Tab> :bnext<CR>
nnoremap <S-Tab> :bprevious<CR>
nnoremap <leader>bd :bdelete<CR>
nnoremap <leader>bu <C-^><CR>
" CURSOR SHAPE
let &t_SI = "\<Esc>[6 q" " SI = Start Insert mode -> cursor em linha
let &t_EI = "\<Esc>[2 q" " EI = End Insert mode -> cursor em bloco (Normal mode)
set guicursor=n-v-c:block,i-ci-ve:ver25,r-cr:hor20,o:hor50
" Really Simple Auto Session (KISS)
let s:sessions_dir = split(&runtimepath, ',')[0] . '/sessions'
function! s:session_id() abort
" usa cwd e sanitiza para nome de arquivo
let l:cwd = getcwd()
return tolower(substitute(l:cwd, '[^A-Za-z0-9_.-]', '_', 'g'))
endfunction
function! s:session_path() abort
return s:sessions_dir . '/' . s:session_id() . '.vim'
endfunction
if !isdirectory(s:sessions_dir)
call mkdir(s:sessions_dir, 'p')
endif
augroup SimpleAutoSession
autocmd!
autocmd VimEnter * call s:maybe_load()
autocmd VimLeavePre * call s:maybe_save()
augroup END
function! s:maybe_load() abort
if argc() > 0
return
endif
let l:path = s:session_path()
if filereadable(l:path)
execute 'source' fnameescape(l:path)
endif
endfunction
function! s:maybe_save() abort
if argc() > 0
return
endif
let l:path = s:session_path()
execute 'mksession!' fnameescape(l:path)
endfunction

Apply Script

The script bellow applies this entire gist for you. The first part is for normal users (no sudo required). To rest if for the root user. The only difference is that the second part uses sudo to target the root user.

# Normal users
curl -fSsL https://gist.githubusercontent.com/luizomf/9a52ba5b7b43aa69cc9a7121795bb9fa/raw/7c0a886860f4bb307bd3103d722f23745d240bcb/run | bash
. ~/.bashrc

# For root use sudo
curl -fSsL https://gist.githubusercontent.com/luizomf/9a52ba5b7b43aa69cc9a7121795bb9fa/raw/7c0a886860f4bb307bd3103d722f23745d240bcb/run | sudo bash
. ~/.bashrc

Both scripts will add something to your ~/.bashrc.

set -o vi
export EDITOR=vim
export VISUAL=vim
export __SETUP_LOADED__=1
bind -m vi-insert '"jj": vi-movement-mode'
#!/usr/bin/env bash
GIST_BASE='https://gist.githubusercontent.com/luizomf/9a52ba5b7b43aa69cc9a7121795bb9fa/raw/2f781b3bebda1fad14016d7ced7884c7e06ed3c8'
main() {
if [[ ! -f "${HOME}/.vimrc" ]]; then
curl -fsSL "$GIST_BASE/.vimrc" -o "${HOME}/.vimrc"
fi
if [[ ! -f "${HOME}/.profile" ]]; then
curl -fsSL "$GIST_BASE/.profile" -o "${HOME}/.profile"
fi
if [[ ! -f "${HOME}/.bashrc" ]]; then
cp /etc/skel/.bashrc "${HOME}/.bashrc"
fi
if ! grep -q "__SETUP_LOADED__=1" "${HOME}/.bashrc"; then
curl -fsSL "$GIST_BASE/bash_minimal_setup" | tee -a "${HOME}/.bashrc" >/dev/null
fi
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment