Last active
December 31, 2023 01:33
-
-
Save samkhn/acc568fcd8e7c7cc535b0097e697ed86 to your computer and use it in GitHub Desktop.
dotfiles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Prompt customization | |
# PROMPT_COMMAND='echo' | |
PS1='\w $ ' | |
export PS1 | |
export EDITOR="vim" | |
alias e="vim" | |
alias vi="vim" | |
session_name="main" | |
tmux has-session -t=$session_name 2> /dev/null | |
if [[ $? -ne 0 ]]; then | |
TMUX='' tmux new-session -d -s "$session_name" | |
fi | |
if [[ -z "$TMUX" ]]; then | |
tmux attach -t "$session_name" | |
else | |
tmux switch-client -t "$session_name" | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Plugins | |
" if empty(glob('~/.vim/autoload/plug.vim')) | |
" if has('win32') | |
" silent !iwr -useb https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim |`ni $HOME/vimfiles/autoload/plug.vim -Force | |
" else | |
" silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim | |
" endif | |
" source ~/.vimrc " this needs to be added | |
" endif | |
" | |
" call plug#begin() | |
" Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } | |
" Plug 'junegunn/fzf.vim' | |
" Plug 'prabirshrestha/asyncomplete.vim' | |
" Plug 'prabirshrestha/vim-lsp' | |
" Plug 'prabirshrestha/asyncomplete-lsp.vim' | |
" Plug 'mattn/vim-lsp-settings' | |
" Plug 'liuchengxu/vista.vim' | |
" Plug 'rust-lang/rust.vim' | |
" Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' } | |
" call plug#end() | |
" | |
" function! s:on_lsp_buffer_enabled() abort | |
" setlocal omnifunc=lsp#complete | |
" setlocal signcolumn=yes | |
" if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif | |
" nmap <buffer> gd <plug>(lsp-definition) | |
" nmap <buffer> gs <plug>(lsp-document-symbol-search) | |
" nmap <buffer> gS <plug>(lsp-workspace-symbol-search) | |
" nmap <buffer> gr <plug>(lsp-references) | |
" nmap <buffer> gi <plug>(lsp-implementation) | |
" nmap <buffer> gt <plug>(lsp-type-definition) | |
" nmap <buffer> ge <plug>(lsp-document-diagnostics) | |
" nmap <buffer> <leader>rn <plug>(lsp-rename) | |
" nmap <buffer> [g <plug>(lsp-previous-diagnostic) | |
" nmap <buffer> ]g <plug>(lsp-next-diagnostic) | |
" nmap <buffer> K <plug>(lsp-hover) | |
" nnoremap <buffer> <expr><c-f> lsp#scroll(+4) | |
" nnoremap <buffer> <expr><c-d> lsp#scroll(-4) | |
" let g:lsp_format_sync_timeout = 1000 | |
" let g:lsp_hover_ui = 'float' | |
" "let g:lsp_inlay_hints_enabled = 1 " this requires vim9 | |
" let g:lsp_diagnostics_virtual_text_align = "right" | |
" autocmd! BufWritePre *.rs,*.go call execute('LspDocumentFormatSync') | |
" endfunction | |
" | |
" augroup lsp_install | |
" au! | |
" " call s:on_lsp_buffer_enabled only for languages that has the server registered. | |
" autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled() | |
" augroup END | |
" | |
" nnoremap <leader>f :GFiles<Cr> | |
" nnoremap <silent><leader>b :Buffers<CR> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set -g default-terminal "tmux-256color" | |
set -g history-limit 10000 | |
set -g base-index 1 | |
setw -g pane-base-index 1 | |
set -g mouse on | |
setw -g mode-keys vi | |
set -sg escape-time 1 | |
set -g renumber-windows on | |
bind '"' split-window -c "#{pane_current_path}" | |
bind % split-window -h -c "#{pane_current_path}" | |
bind c new-window -c "#{pane_current_path}" | |
unbind r | |
bind r source-file ~/.tmux.conf \; display "Reloaded tmux config!" | |
# set -g status-style fg=black,bg=white | |
set -sg escape-time 0 | |
set -g mouse on | |
unbind -T copy-mode MouseDragEnd1Pane | |
bind-key -T copy-mode-vi MouseDragEnd1Pane send -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy" | |
set-option -g status off | |
set-option -g status-interval 1 | |
set-option -g status-justify centre | |
set-option -g status-keys vi | |
set-option -g status-position bottom | |
set-option -g status-style fg=white,bg=colour235 | |
set-option -g status-left-length 20 | |
set-option -g status-left-style default | |
set-option -g status-left "#(whoami)#[default]" | |
set-option -g status-right-length 140 | |
set-option -g status-right-style default | |
set-option -g status-right '#[fg=white]%Y-%m-%d %H:%M' | |
set-window-option -g window-status-style fg=colour244 | |
set-window-option -g window-status-style bg=default | |
set-window-option -g window-status-current-style fg=colour166 | |
set-window-option -g window-status-current-style bg=default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set nocompatible | |
set noerrorbells | |
set backspace=indent,eol,start | |
set showcmd | |
set backup | |
set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp | |
set backupskip=/tmp/*,/private/tmp/* | |
set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp | |
set writebackup | |
set splitright | |
set splitbelow | |
set encoding=utf-8 | |
set fileformats=unix,dos,mac | |
set autoread | |
au FocusGained,BufEnter,CursorHold * checktime | |
"set number | |
"set cursorline | |
set ruler | |
" netrw/nerdtree | |
let g:netrw_banner = 0 | |
let g:netrw_liststyle = 3 | |
let g:netrw_browse_split = 4 | |
let g:netrw_altv = 1 | |
let g:netrw_winsize = 25 | |
let g:netrw_list_hide=netrw_gitignore#Hide() | |
let g:NetrwIsOpen=0 | |
function! ToggleNetrw() | |
if g:NetrwIsOpen | |
let i = bufnr("$") | |
while (i >= 1) | |
if (getbufvar(i, "&filetype") == "netrw") | |
silent exe "bwipeout " . i | |
endif | |
let i-=1 | |
endwhile | |
let g:NetrwIsOpen=0 | |
else | |
let g:NetrwIsOpen=1 | |
silent Lexplore | |
endif | |
endfunction | |
map <leader>fs :call ToggleNetrw()<CR> | |
nnoremap <leader>ca :%bd\|e#<CR> | |
" If editing a file with sudo priveleges... | |
command W :execute ':silent w !sudo tee % > /dev/null' | :edit! | |
set nowrap | |
set ttyfast | |
set nofoldenable | |
filetype off | |
filetype plugin off | |
filetype indent on | |
set title | |
" set laststatus=2 | |
set path+=** | |
set wildmenu | |
set lazyredraw | |
set showmatch " show matching parens | |
" searching | |
set ignorecase | |
set smartcase | |
set incsearch | |
set hlsearch | |
nnoremap <leader><space> :nohlsearch<CR> | |
" Move a line of text with Alt JK | |
nmap <M-j> mz:m+<cr>`z | |
nmap <M-k> mz:m-2<cr>`z | |
vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z | |
vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z | |
" Formattings and indenting | |
set autoindent | |
set smartindent | |
set smarttab | |
set tabstop=4 | |
set shiftwidth=4 | |
au Filetype gitcommit setlocal spell textwidth=72 | |
au BufNewFile,BufRead *.vim setlocal noet ts=4 sw=4 sts=4 | |
au BufNewFile,BufRead *.txt setlocal noet ts=4 sw=4 | |
au BufNewFile,BufRead *.md setlocal noet ts=4 sw=4 | |
au BufNewFile,BufRead *.yml,*.yaml setlocal expandtab ts=2 sw=2 | |
au BufRead,BufNewFile MAINTAINERS,*.toml set ft=toml formatprg=toml-fmt | |
au BufNewFile,BufRead *.hpp,*.cc,*.cpp setlocal expandtab ts=2 sw=2 | |
au BufNewFile,BufRead */linux/** setlocal noet ts=8 sw=8 | |
au BufNewFile,BufRead *.h,*.c setlocal noet ts=8 sw=8 | |
au BufNewFile,BufRead *.rs setlocal expandtab ts=4 sw=4 | |
au BufNewFile,BufRead *.go setlocal noet ts=8 sw=8 sts=8 | |
au BufNewFile,BufRead *.py setlocal tabstop=4 softtabstop=4 shiftwidth=4 textwidth=80 smarttab expandtab | |
au BufNewFile,BufRead *.hs setlocal expandtab ts=8 sw=8 | |
" For when we use xxd | |
" ex: $ xxd /bin/ls | vim - | |
augroup Binary | |
au! | |
au BufReadPre *.bin let &bin=1 | |
au BufReadPost *.bin if &bin | %!xxd | |
au BufReadPost *.bin set ft=xxd | endif | |
au BufWritePre *.bin if &bin | %!xxd -r | |
au BufWritePre *.bin endif | |
au BufWritePost *.bin if &bin | %!xxd | |
au BufWritePost *.bin set nomod | endif | |
augroup END | |
if executable('csearch') | |
function CSearch(folder, pattern) | |
let search_command = printf("csearch -n -f %s '%s'", a:folder, a:pattern) | |
cgetexpr system(search_command) | copen | |
:echom "results for " . search_command | |
endfunction | |
" Usage: `:CSearch "googletest","#define EXPECT_TRUE"` | |
" Two quoted strings, first is a fileregexp, second is regexp to read | |
" Quoted args must be together with comma between them | |
command -nargs=* CSearch call CSearch(<args>) | |
function CSearchRepo(pattern) | |
let search_command = printf("csearch -n -f ^$(git rev-parse --show-toplevel || pwd) %s", a:pattern) | |
cgetexpr system(search_command) | copen | |
:echom "results for " . search_command | |
endfunction | |
" Usage: `:CSearchRepo "regexp"` | |
command -nargs=1 CSearchRepo call CSearchRepo(<q-args>) | |
nnoremap <Leader>cs :CSearchRepo | |
nnoremap <Leader>cg :CSearch | |
endif | |
if executable("rg") | |
set grepprg=rg\ --vimgrep\ --smart-case\ --hidden | |
set grepformat=%f:%l:%c:%m | |
endif | |
function! Grep(...) | |
return system(join([&grepprg] + [expandcmd(join(a:000, ' '))], ' ')) | |
endfunction | |
command! -nargs=+ -complete=file_in_path -bar Grep cgetexpr Grep(<f-args>) | |
command! -nargs=+ -complete=file_in_path -bar LGrep lgetexpr Grep(<f-args>) | |
cnoreabbrev <expr> grep (getcmdtype() ==# ':' && getcmdline() ==# 'grep') ? 'Grep' : 'grep' | |
cnoreabbrev <expr> lgrep (getcmdtype() ==# ':' && getcmdline() ==# 'lgrep') ? 'LGrep' : 'lgrep' | |
augroup quickfix | |
autocmd! | |
autocmd QuickFixCmdPost cgetexpr cwindow | |
autocmd QuickFixCmdPost lgetexpr lwindow | |
augroup END | |
"nnoremap <leader>m :silent make\|redraw!\|copen<CR> | |
"let &makeprg = 'bash -c ./build.sh' | |
"if has('win32') | |
" let &makeprg = 'build.bat' | |
"endif | |
nnoremap <leader>b :silent vert term ./build.sh \| copen<CR> | |
if has('win32') | |
nnoremap <leader>b :silent vert term ./build.bat<CR> | |
endif | |
if has('mouse') | |
set mouse=a | |
endif | |
" A weird one... using jh to escape | |
" inoremap jh <Esc> | |
" This changes cursor to vertical bar for xterm, git-bash (win32) | |
let &t_SI = "\e[6 q" | |
let &t_EI = "\e[2 q" | |
" reset the cursor on start (for older versions of vim, usually not required) | |
augroup myCmds | |
au! | |
autocmd VimEnter * silent !echo -ne "\e[2 q" | |
augroup END | |
" visuals | |
syntax off | |
try | |
"colorscheme quiet | |
catch /^Vim\%((\a\+)\)\=:E185/ | |
colorscheme default | |
endtry | |
set fillchars+=vert:\│ | |
if has("gui_running") | |
set lines=40 | |
set columns=100 | |
set guioptions-=m "no menu bar | |
set guioptions-=T "no toolbar | |
set guioptions-=r "no right scrollbar | |
set guioptions-=L "no left scrollbar | |
set guifont=Monospace\ 10 | |
endif | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Install debian or similar Linux based distribution | |
In $HOME, create build, install, src directories | |
Have Yubikey or similar on hand | |
Install modern browser (sync to Google Account, login to Github), have downloads go to $HOME/get | |
Install ssh, git | |
$ git config --global user.name “Samiur Khan” | |
Generate SSH key tied to physical key, add to github | |
Grab .tmux.conf (no plugins) | |
Grab .vimrc (no lsp or fancy plugin) | |
Grab .bashrc (adding aliases to command line tools, modifying path to include newly installed binaries) | |
$ sudo apt-get install build-essential ninja make libncurses5-dev vim vim-gtk3 tmux cmake gcc gdb g++ make git exuberant-ctags bc flex bison autoconf libssl-dev linux-tools-common linux-tools-generic linux-tools-`uname -r` libstdc++-static lld clang-format |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment