Skip to content

Instantly share code, notes, and snippets.

@FateNozomi

FateNozomi/.bashrc

Created Jun 30, 2020
Embed
What would you like to do?
Env
# Change command prompt
if grep -qE "(Microsoft|WSL)" /proc/version &> /dev/null ; then
export PS1='\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[36m\]$(__git_ps1)\[\033[00m\]\n\$ '
else
export PS1='\[\033]0;$PWD\007\]\[\033[32m\]\u@\h:\[\033[33m\]\w\[\033[36m\]`__git_ps1`\[\033[0m\]\n$ '
fi
# Set default editor
export EDITOR="vim"
# Git prompt features (read ~/.git-prompt.sh for reference)¬
export GIT_PS1_SHOWDIRTYSTATE="true"
# Alias
if grep -qE "(Microsoft|WSL)" /proc/version &> /dev/null ; then
alias home="cd /mnt/c"
else
alias home="cd /c"
fi
# Auto-launch ssh-agent on Git Bash
env=~/.ssh/agent.env
agent_load_env () { test -f "$env" && . "$env" >| /dev/null ; }
agent_start () {
(umask 077; ssh-agent >| "$env")
. "$env" >| /dev/null ; }
agent_load_env
# agent_run_state: 0=agent running w/ key; 1=agent w/o key; 2= agent not running
agent_run_state=$(ssh-add -l >| /dev/null 2>&1; echo $?)
if [ ! "$SSH_AUTH_SOCK" ] || [ $agent_run_state = 2 ]; then
agent_start
ssh-add -t 36000
elif [ "$SSH_AUTH_SOCK" ] && [ $agent_run_state = 1 ]; then
ssh-add -t 36000
fi
unset env
ForegroundColour=131,148,150
BackgroundColour=0,43,54
CursorColour=220,50,47
Black=7,54,66
BoldBlack=0,43,54
Red=220,50,47
BoldRed=203,75,22
Green=133,153,0
BoldGreen=88,110,117
Yellow=181,137,0
BoldYellow=101,123,131
Blue=38,139,210
BoldBlue=131,148,150
Magenta=211,54,130
BoldMagenta=108,113,196
Cyan=42,161,152
BoldCyan=147,161,161
White=238,232,213
BoldWhite=253,246,227
BoldAsFont=yes
BoldAsColour=yes
Term=xterm-256color
Font=Ubuntu Mono
FontHeight=12
CursorType=block
Columns=100
Rows=30
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" -> General
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Set Windows gvim runtimepath to match Unix systems
if has('win32') || has('win64')
set runtimepath+=~/.vim
endif
" Runtime Path Manipulation using Pathogen
execute pathogen#infect()
" Enable filetype plugins
filetype plugin on
filetype indent on
" Set to auto read when a file is changed from the outside
set autoread
" Fast saving
nmap <leader>w :w!<cr>
" Clear buffers
map <leader>q :bp<bar>sp<bar>bn<bar>bd<cr>
" Copy to system clipboard
map <leader>c "+y
" Paste from system clipboard
map <leader>v "+p
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" -> VIM user interface
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Set 7 lines to the cursor - when moving vertically using j/k
set so=7
" Turn on visual autocompletion for command menu
set wildmenu
"Always show current position
set ruler
" Always show line numbers
set number
" Highlight current line
set cursorline
" Height of the command bar
set cmdheight=2
" Configure backspace in insert mode
set backspace=indent,eol,start
" Make search smarter about cases
set ignorecase
set smartcase
" Move cursor to pattern while searching
set incsearch
" Highlight search results
set hlsearch
" Bind <ctrl+n> and <enter> to turn off search highlighting
nnoremap<C-n> :noh<cr>
nnoremap<enter> :noh<cr>
" Bind <ctrl+c> to copy to system clipboard
vnoremap <C-c> "+y
" Set extra options when running in GUI mode
if has("gui_running")
set lines=30 columns=100
endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" -> Colors and Fonts
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Enable syntax highlighting
syntax enable
"Colorscheme
"set termguicolors
let g:gruvbox_contrast_dark = 'hard'
let g:gruvbox_italic = 1
colorscheme gruvbox
set background=dark
" Set utf8 as standard encoding and en_US as the standard language
set encoding=utf-8
" Display whitespace characters
set list!
set listchars=eol:¬,tab:>―,trail:~,extends:>,precedes:<
" Set font family and size
set guifont:Ubuntu\ Mono:h12
" Set extra options when running in GUI mode
if has("gui_running")
set t_Co=256
endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" -> Files, backups and undo
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Turn backup off
set nobackup
set nowb
set noswapfile
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" -> Text, tab and indent related
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Use spaces instead of tabs
set expandtab
" 'smarttab' affects how <TAB> key presses are interpreted depending
" on where the cursor is. If 'smarttab' is on, a <TAB> key inserts
" indentation according to 'shiftwidth' at the beginning of the line,
" whereas 'tabstop' and 'softtabstop' are used elsewhere. There is
" seldom any need to set this option, unless it is necessary to use
" hard TAB characters in body text or code.
set smarttab
" 1 tab == 4 spaces
set shiftwidth=4
set tabstop=4
" Auto indent
set ai
" Smart indent
set si
" Wrap lines
set wrap
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" -> Spell checking
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Pressing /ss will toggle and untoggle spell checking
map <leader>ss :setlocal spell!<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" -> Plugins
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Airline
let g:airline_theme = 'gruvbox'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.