dotfiles

Cross platform dotfiles for linux, mac and windows
git clone git@getsh.org:dotfiles.git
Log | Files | Refs

commit f4f5eba6cc351c4ce606b91f9e50b7bebe9d869d
parent 27bdf8bca13c1b77a76c81b89ddb5563567988a2
Author: Bharatvaj <bharatvaj@yahoo.com>
Date:   Tue,  7 Sep 2021 06:14:57 +0530

Merge pull request #11 from bharatvaj/bharat-9052

Use vi mode for bash
Diffstat:
M.bash_profile | 5+++--
M.config/.gitignore | 6+++---
M.config/bash/bashrc | 2++
M.config/bash/plugin/git | 1-
M.config/bash/plugin/index | 2++
A.config/bash/plugin/nb | 9+++++++++
A.config/bash/plugin/shorthand | 7+++++++
A.config/vim/keybindings/keybindings.vim | 7+++++++
A.config/vim/keybindings/markdown.vim | 4++++
A.config/vim/keybindings/vimspector.vim | 25+++++++++++++++++++++++++
A.config/vim/plugin/development.vim | 7+++++++
A.config/vim/plugin/plugin.vim | 26++++++++++++++++++++++++++
M.config/vim/vimrc | 42+++++++++++-------------------------------
M.gitignore | 3+++
A.local/bin/jrnl | 11+++++++++++
A.local/bin/jrnl_sync | 5+++++
M.profile | 6+++++-
DX11.md | 12------------
18 files changed, 130 insertions(+), 50 deletions(-)

diff --git a/.bash_profile b/.bash_profile @@ -1,10 +1,11 @@ # If not running interactively, don't do anything [[ $- != *i* ]] && return +set -o vi + [ -f ~/.profile ] && . ~/.profile -[ -f ~/.personal/config ] && . ~/.personal/config +[ -f "${XDG_DATA_HOME}/personal/config" ] && . "${XDG_DATA_HOME}/personal/config" [ -f "${XDG_CONFIG_HOME}/bash/bashrc" ] && . "${XDG_CONFIG_HOME}"/bash/bashrc # Zoho [ -f ~/.zoho/zoho ] && . ~/.zoho/zoho - diff --git a/.config/.gitignore b/.config/.gitignore @@ -3,13 +3,13 @@ !.gitignore !alacritty/ -!alacritty/* +!alacritty/** !bash/ -!bash/* +!bash/** !i3 !nvim !vim/ -!vim/* +!vim/** !X11 !wgetrc !user-dirs.dirs diff --git a/.config/bash/bashrc b/.config/bash/bashrc @@ -15,6 +15,8 @@ done export PS1="\w $ " +shopt -s autocd + # Plugins [ -f "${XDG_CONFIG_HOME}/bash/plugin/index" ] && . "${XDG_CONFIG_HOME}/bash/plugin/index" diff --git a/.config/bash/plugin/git b/.config/bash/plugin/git @@ -17,7 +17,6 @@ alias gcos='git checkout staging' alias gcod='git checkout develop' alias gd='git diff' alias gda='git diff HEAD' -alias gi='git init' alias glg='git log --graph --oneline --decorate --all' alias gld='git log --pretty=format:"%h %ad %s" --date=short --all' alias gm='git merge --no-ff' diff --git a/.config/bash/plugin/index b/.config/bash/plugin/index @@ -11,3 +11,5 @@ function bashplug() { # Enable this plugin if 'git' is installed which git >&/dev/null && bashplug git +which ranger >&/dev/null && bashplug nb +bashplug shorthand diff --git a/.config/bash/plugin/nb b/.config/bash/plugin/nb @@ -0,0 +1,9 @@ +# nb - notebook +NB_PATH="${XDG_DATA_HOME}/notes" + +nb() { + cd "${NB_PATH}" + file="$(fzf --preview='cat {}')" + [ "${file}" != "" ] && vim "${file}" +} + diff --git a/.config/bash/plugin/shorthand b/.config/bash/plugin/shorthand @@ -0,0 +1,7 @@ +# One letter bindings for important commands + +[ ! -z "${EDITOR}" ] && alias e=${EDITOR} + +which git >&/dev/null && alias g=git + +which pass >&/dev/null & alias p=pass diff --git a/.config/vim/keybindings/keybindings.vim b/.config/vim/keybindings/keybindings.vim @@ -0,0 +1,7 @@ +" General keybindings +nnoremap <leader>t :tabnew<cr> +nnoremap <leader>p :Rg<cr> + +" Plugin keybindings +source $XDG_CONFIG_HOME/vim/keybindings/vimspector.vim +source $XDG_CONFIG_HOME/vim/keybindings/markdown.vim diff --git a/.config/vim/keybindings/markdown.vim b/.config/vim/keybindings/markdown.vim @@ -0,0 +1,4 @@ +autocmd FileType markdown set cursorline + +" Hide and format markdown elements like **bold** +autocmd FileType markdown set conceallevel=2 diff --git a/.config/vim/keybindings/vimspector.vim b/.config/vim/keybindings/vimspector.vim @@ -0,0 +1,25 @@ +fun! GotoWindow(id) + call win_gotoid(a:id) +endfun + +" Debugger remaps +nnoremap <leader>dd :call vimspector#Launch()<CR> +nnoremap <leader>dc :call GotoWindow(g:vimspector_session_windows.code)<CR> +nnoremap <leader>dt :call GotoWindow(g:vimspector_session_windows.tagpage)<CR> +nnoremap <leader>dv :call GotoWindow(g:vimspector_session_windows.variables)<CR> +nnoremap <leader>dw :call GotoWindow(g:vimspector_session_windows.watches)<CR> +nnoremap <leader>ds :call GotoWindow(g:vimspector_session_windows.stack_trace)<CR> +nnoremap <leader>do :call GotoWindow(g:vimspector_session_windows.output)<CR> +nnoremap <leader>de :call vimspector#Reset()<CR> + +nnoremap <leader>dtcb :call vimspector#CleanLineBreakpoint()<CR> + +nmap <leader>dl <Plug>VimspectorStepInto +nmap <leader>dj <Plug>VimspectorStepOver +nmap <leader>dk <Plug>VimspectorStepOut +nmap <leader>d_ <Plug>VimspectorRestart +nnoremap <leader>d<space> :call vimspector#Continue()<CR> + +nmap <leader>drc <Plug>VimspectorRunToCursor +nmap <leader>dbp <Plug>VimspectorToggleBreakpoint +nmap <leader>dcbp <Plug>VimspectorToggleConditionalBreakpoint diff --git a/.config/vim/plugin/development.vim b/.config/vim/plugin/development.vim @@ -0,0 +1,7 @@ +Plug 'editorconfig/editorconfig-vim' +Plug 'cdelledonne/vim-cmake' +if has('nvim') + Plug 'puremourning/vimspector' +endif +Plug 'vim-syntastic/syntastic' +Plug 'rust-lang/rust.vim' diff --git a/.config/vim/plugin/plugin.vim b/.config/vim/plugin/plugin.vim @@ -0,0 +1,26 @@ +" Plugin Management +function DownloadPlug() + let data_dir = has('nvim') ? stdpath('data') . '/site' : "${XDG_DATA_HOME}/vim" + if empty(glob(data_dir . '/autoload/plug.vim')) + silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' + PlugInstall --sync | source $MYVIMRC + endif +endfunction + +call plug#begin($XDG_DATA_HOME."/vim/plugged") + Plug 'tpope/vim-commentary' + Plug 'tpope/vim-surround' + Plug 'itchyny/lightline.vim' + Plug 'tpope/vim-fugitive' + Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } + Plug 'junegunn/fzf.vim' + source $XDG_CONFIG_HOME/vim/plugin/development.vim +call plug#end() + +" Plugin Keybindings + +" fzf +nmap <leader>F :GFiles<cr> +nmap <leader>f :Files<cr> + +nnoremap <leader>cc :ChecklistToggleCheckbox<cr> diff --git a/.config/vim/vimrc b/.config/vim/vimrc @@ -30,12 +30,16 @@ set mouse=a syntax on set exrc +" Map leader to space +nnoremap <SPACE> <Nop> +let mapleader = " " + " Disable auto fixing end of line " Useful when opening binary files set nofixendofline " Disable vim intro message -set shortmess=I +set shortmess=Iat " Search set hlsearch @@ -57,33 +61,9 @@ for key in ['<Up>', '<Down>', '<Left>', '<Right>'] exec 'cnoremap' key '<Nop>' endfor -" Plugin Management -"let data_dir = has('nvim') ? stdpath('data') . '/site' : "${XDG_DATA_HOME}/vim" -"if empty(glob(data_dir . '/autoload/plug.vim')) -" silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' -" autocmd VimEnter * PlugInstall --sync | source $MYVIMRC -"endif -call plug#begin($XDG_DATA_HOME."/vim/plugged") - Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } - Plug 'junegunn/fzf.vim' - Plug 'cdelledonne/vim-cmake' - Plug 'editorconfig/editorconfig-vim' - Plug 'tpope/vim-fugitive' - Plug 'tpope/vim-surround' -call plug#end() - -" Plugin customizations -" fzf -" BUG remove bashism -" TODO - Files are repeated twice in some cases -command! GFAll call fzf#run(fzf#wrap({'source': "comm <(git ls-files --exclude-standard --cached --cached --recurse-submodules) <(git ls-files --exclude-standard --cached --others) | awk '{$1=$1;print}'"})) - -" Plugin Keybindings -nmap <leader>f :GFAll<cr> -nmap <leader>F :Files<cr> -nnoremap <leader>t :tabnew<cr> -nnoremap <leader>p :Rg<cr> -nnoremap <leader>s :source ~/.config/vim/vimrc<cr> - -" Theming Begin -" Theming End +" Plugins +source $XDG_CONFIG_HOME/vim/plugin/plugin.vim + +" Keybindings +source $XDG_CONFIG_HOME/vim/keybindings/keybindings.vim + diff --git a/.gitignore b/.gitignore @@ -14,3 +14,6 @@ # Config !.config/ +# Local shell scripts +!.local/bin/ +!.local/bin/* diff --git a/.local/bin/jrnl b/.local/bin/jrnl @@ -0,0 +1,11 @@ +#!/bin/sh + + jrnl_path="${XDG_DATA_HOME}/notes" + +if [ -d "${jrnl_path}" ]; then + ranger "${jrnl_path}" +else + cd "${jrnl_path}" + vim "$(fzf --preview 'cat {}')" +fi + diff --git a/.local/bin/jrnl_sync b/.local/bin/jrnl_sync @@ -0,0 +1,5 @@ +#!/bin/sh + + jrnl_path="${XDG_DATA_HOME}/notes" + +git --git-dir="${jrnl_path}/.git" add "${jrnl_path}/contents" && git --git-dir="${jrnl_path}/.git" commit "$(date)" diff --git a/.profile b/.profile @@ -8,6 +8,7 @@ export XDG_CACHE_HOME="$HOME/.cache" export GNUPGHOME="$XDG_DATA_HOME/gnupg" export VIMINIT='source $XDG_CONFIG_HOME/vim/vimrc' export LESSHISTFILE=- +export LYNX_CFG="$XDG_CONFIG_HOME/lynx/lynx.cfg" export NODE_REPL_HISTORY="$XDG_DATA_HOME"/node_repl_history export NPM_CONFIG_USERCONFIG=$XDG_CONFIG_HOME/npm/npmrc export PASSWORD_STORE_DIR="$XDG_DATA_HOME"/pass @@ -16,6 +17,7 @@ export PSQL_HISTORY="$XDG_CACHE_HOME/pg/psql_history" export PGPASSFILE="$XDG_CONFIG_HOME/pg/pgpass" export PGSERVICEFILE="$XDG_CONFIG_HOME/pg/pg_service.conf" export RUSTUP_HOME="$XDG_DATA_HOME"/rustup +export TASKRC="$XDG_CONFIG_HOME/task/taskrc" export HISTFILE="$XDG_DATA_HOME"/bash/history export XINITRC="$XDG_CONFIG_HOME"/X11/xinitrc export XSERVERRC="$XDG_CONFIG_HOME"/X11/xserverrc @@ -25,6 +27,8 @@ export WGETRC="$XDG_CONFIG_HOME/wgetrc" export SCREENRC="$XDG_CONFIG_HOME"/screen/screenrc # Setup editor -export EDITOR=vim export VISUAL=vim +export EDITOR="$VISUAL" +# Local executables +export PATH=${PATH}:~/.local/bin diff --git a/X11.md b/X11.md @@ -1,12 +0,0 @@ -# X11 - -``` -# Launch firefox as user without xorg -# .config/X11/xinitrc file should be cleared for this to work, otherwise it would launch i3 -xinit firefox $* -- :0 vt$XDG_VTNR - - -# Configure xauth manually -# $HOST was not defined in arch, I added it manually when using it -xauth add ${HOST}:0 . $(xxd -l 16 -p /dev/urandom) -```