dotfiles

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

commit df6376885b8d28599d7c25f24955fa7a3b63de55
parent 6accd29e460772f819a43bfbc0e21eb6a7a322e2
Author: Bharatvaj <bharatvaj@yahoo.com>
Date:   Mon,  4 Jul 2022 18:37:14 +0530

Merge branch 'base' of getsh.org:dotfiles into base

Diffstat:
M.config/.gitignore | 9+++++++--
A.config/clink/clink_settings | 2++
A.config/cmd/aliases.bat | 6++++++
D.config/cmd/aliases.cmd | 5-----
A.config/cmd/env.bat | 15+++++++++++++++
M.config/cmd/profile.cmd | 9+++------
A.config/cmd/setup.cmd | 15+++++++++++++++
M.config/cmd/setup.ps1 | 6+++---
A.config/nvim/lua/keybindings.lua | 10++++++++++
M.config/sh/aliases | 2+-
M.config/sh/functions | 2+-
A.config/vim/gvimrc | 2++
M.config/vim/keybindings/keybindings.vim | 23+++++++++++++++++------
M.config/vim/vimrc | 15++++++++-------
M.gitattributes | 2++
M.gitignore | 2+-
M.gitmodules | 3+++
A.local/bin/cmd/j.cmd | 16++++++++++++++++
A.local/bin/cmd/lfcd.cmd | 15+++++++++++++++
D.local/bin/passfind | 21---------------------
A.local/share/vim/pack/general/start/mru | 1+
21 files changed, 128 insertions(+), 53 deletions(-)

diff --git a/.config/.gitignore b/.config/.gitignore @@ -5,11 +5,14 @@ !X11 !alacritty/ !alacritty/** -alacritty/windows.yml !bash/ !bash/** +!clink +!clink/clink_settings +cmd/userenv.bat +!cmd/ +# TODO specify each file individually !cmd/ -!cmd/** !git/ !git/config !i3 @@ -28,3 +31,5 @@ alacritty/windows.yml !vim/ !vim/** !wgetrc + +alacritty/windows.yml diff --git a/.config/clink/clink_settings b/.config/clink/clink_settings @@ -0,0 +1,2 @@ +clink.autostart=%XDG_CONFIG_HOME%\cmd\profile.cmd +clink.logo=none diff --git a/.config/cmd/aliases.bat b/.config/cmd/aliases.bat @@ -0,0 +1,6 @@ +doskey v=vim $* +doskey vi=vim $* +doskey n=nvim $* +doskey g=git $* +doskey e=%EDITOR% $* +doskey l=lfcd.cmd diff --git a/.config/cmd/aliases.cmd b/.config/cmd/aliases.cmd @@ -1,5 +0,0 @@ -doskey v=vim $* -doskey vi=vim $* -doskey n=nvim $* -doskey g=git $* -doskey l=%USERPROFILE%\.config\cmd\lfcd.cmd diff --git a/.config/cmd/env.bat b/.config/cmd/env.bat @@ -0,0 +1,15 @@ +set HOME=%USERPROFILE% +set XDG_CONFIG_HOME=%USERPROFILE%\.config +set XDG_DATA_HOME=%USERPROFILE%\.local\share +set XDG_CACHE_HOME=%USERPROFILE%\.cache +set VISUAL=vim +set EDITOR=%VISUAL% + +set GNUPGHOME=%XDG_DATA_HOME%\gnupg +set PASSWORD_STORE_DIR=%XDG_DATA_HOME%\pass +set PASS_BASE_DIR=%XDG_DATA_HOME%\pass +set NB_PATH=%XDG_DATA_HOME%\notebook + +set MYVIMRC=%XDG_CONFIG_HOME%\vim\vimrc +set VIMINIT=source $MYVIMRC +set PATH=%PATH%;%USERPROFILE%\.local\bin\cmd diff --git a/.config/cmd/profile.cmd b/.config/cmd/profile.cmd @@ -3,10 +3,7 @@ cd %USERPROFILE% prompt $P ∆ -set VISUAL=vim -set EDITOR=%VISUAL% -set XDG_CONFIG_HOME=%USERPROFILE%\.config -set XDG_DATA_HOME=%USERPROFILE%\.local\share -set XDG_CACHE_HOME=%USERPROFILE%\.cache +@call %XDG_CONFIG_HOME%\cmd\env.bat +@call %XDG_CONFIG_HOME%\cmd\userenv.bat -%USERPROFILE%\.config\cmd\aliases.cmd +@call %XDG_CONFIG_HOME%\cmd\aliases.bat diff --git a/.config/cmd/setup.cmd b/.config/cmd/setup.cmd @@ -0,0 +1,15 @@ +@echo off +powershell %XDG_CONFIG_HOME%\cmd\setup.ps1 +@call %XDG_CONFIG_HOME%\cmd\environment.bat + +:: Apply config patches +:: TODO Use mklink instead of xcopy, it will prevent overriding changed files in the destination dir. +xcopy /Y %USERPROFILE%\.config\cmd\patch %USERPROFILE%\ /S /E + +IF NOT EXIST %USERPROFILE%\.config\vim\vimrc mklink %USERPROFILE%\_vimrc %USERPROFILE%\.config\vim\vimrc + +mkdir %SYSTEMDRIVE%\bin +cp %SCOOP%\apps\busybox\current\busybox.exe %SYSTEMDRIVE%\bin +cp %SCOOP%\shims\sh.* %SYSTEMDRIVE%\bin +:: TODO Report this in scoop and remove this line +rm %SCOOP%\apps\gpg\current\bin\gpgconf.ctl diff --git a/.config/cmd/setup.ps1 b/.config/cmd/setup.ps1 @@ -1,10 +1,10 @@ Set-ExecutionPolicy RemoteSigned -scope CurrentUser -# TODO Handle Admin user check +#TODO Make this work for Administrator accounts Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh') # Install the absolute essentials scoop install $(gc ~/.config/cmd/packages.txt) -# Apply config patches -xcopy %USERPROFILE%\.config\cmd\patch %USERPROFILE% /E +# Setup clink +clink autorun set "clink inject --profile %XDG_CONFIG_HOME%\clink" diff --git a/.config/nvim/lua/keybindings.lua b/.config/nvim/lua/keybindings.lua @@ -0,0 +1,10 @@ +local map = require("utils").map +map("n", "<Leader>ww", ":w<CR>", { silent = true }) +map("n", "<Leader>wq", ":wq<CR>", { silent = true }) +map("n", "<Leader>qq", ":q<CR>", { silent = true }) +map("n", "<CR>", ":noh<CR>", { silent = true }) + +map("n", "<leader>f", ":find ", { silent = false }) +map("n", "<leader>co", ":copen<cr>", { silent = false }) +map("n", "<leader>g", ":grep ", { silent = false}) +map("n", "<leader>ec", ":edit ~/.config/nvim/init.lua<cr>", { silent = false}) diff --git a/.config/sh/aliases b/.config/sh/aliases @@ -36,4 +36,4 @@ alias g=git alias l=lfcd alias n='nvim' alias v='vim' -alias x=extract +alias x=extract_archive diff --git a/.config/sh/functions b/.config/sh/functions @@ -1,5 +1,5 @@ # TODO implement [dest_dir] functionality -extract () { +extract_archive () { test $# -lt 1 && { printf "Usage: $0 <archive>\n"; exit 1; } test -f $1 || { printf "$0: $1: No such file \n"; exit 1; } case $1 in diff --git a/.config/vim/gvimrc b/.config/vim/gvimrc @@ -0,0 +1,2 @@ +set guifont=Fira\ Code\ SemiBold +set guioptions= diff --git a/.config/vim/keybindings/keybindings.vim b/.config/vim/keybindings/keybindings.vim @@ -1,14 +1,19 @@ " General keybindings -nnoremap <leader>t :tabnew<cr> -nnoremap <leader>p :Rg<cr> -nnoremap <leader>f :find -nnoremap <Leader>l :ls<CR>:b<space> nmap <leader>F :GFiles<cr> +nnoremap <Leader>l :ls<CR>:b<space> +nnoremap <leader><leader> :grep nnoremap <leader>co :copen<cr> -nnoremap <leader>g :grep nnoremap <leader>ec :edit ~/.config/vim/vimrc<cr> +nnoremap <leader>f :find +nnoremap <leader>g :grep +nnoremap <leader>p :Rg<cr> +nnoremap <leader>t :tabnew<cr> nnoremap Y y$ + +fun! GitFind() +endfun + fun! SetupCommandAlias(from, to) exec 'cnoreabbrev <expr> '.a:from \ .' ((getcmdtype() is# ":" && getcmdline() is# "'.a:from.'")' @@ -37,7 +42,13 @@ nnoremap <leader>ww :w<cr> nnoremap <leader>qq :q<cr> " Run Make -nnoremap <leader>bb :Make<CR> + +function SaveAndBuild() + wall + Make +endfunction + +nnoremap <leader>bb :call SaveAndBuild()<CR> " Generate ctags map <leader>c :!ctags -R -f ./.git/tags .<CR> diff --git a/.config/vim/vimrc b/.config/vim/vimrc @@ -84,14 +84,15 @@ augroup user_cmds autocmd VimEnter * call timer_start(20, function('s:load_plugins')) augroup END +if has("gui") + source $XDG_CONFIG_HOME/vim/gvimrc +endif + if has("win32") - if executable("pwsh") - set shell=pwsh - set shellcmdflag=-ExecutionPolicy\ RemoteSigned\ -Command - set shellquote=\" - " shellxquote must be a literal space character. - set shellxquote= - endif + set shell=cmd + set shellquote=\" + " shellxquote must be a literal space character. + set shellxquote= endif set fillchars+=eob:\ diff --git a/.gitattributes b/.gitattributes @@ -1 +1,3 @@ * text eol=lf +*.cmd text eol=crlf +*.bat text eol=crlf diff --git a/.gitignore b/.gitignore @@ -17,7 +17,7 @@ # Local shell scripts !.local/ !.local/bin/ -!.local/bin/* +!.local/bin/** # !.local/share/vim/pack/**/start/** # !.local/share/vim/pack/**/opt/** diff --git a/.gitmodules b/.gitmodules @@ -58,3 +58,6 @@ [submodule ".local/share/vim/pack/general/start/vim-dispatch"] path = .local/share/vim/pack/general/start/vim-dispatch url = https://github.com/tpope/vim-dispatch +[submodule ".local/share/vim/pack/general/start/mru"] + path = .local/share/vim/pack/general/start/mru + url = https://github.com/yegappan/mru diff --git a/.local/bin/cmd/j.cmd b/.local/bin/cmd/j.cmd @@ -0,0 +1,16 @@ +@echo off +setlocal EnableDelayedExpansion + +for /f "delims=" %%i in ('"autojump.exe" %*') do set new_path=%%i +if exist !new_path!\nul ( +echo "!new_path!" +pushd "!new_path!" +REM endlocal is necessary so that we can change directory for outside of this script +REM but will automatically popd. We mush pushd twice to work around this. +pushd "!new_path!" +endlocal +popd +) else ( +echo autojump: directory %* not found +echo try `autojump --help` for more information +) diff --git a/.local/bin/cmd/lfcd.cmd b/.local/bin/cmd/lfcd.cmd @@ -0,0 +1,15 @@ +@echo off +rem Change working dir in cmd.exe to last dir in lf on exit. +rem +rem You need to put this file to a folder in %PATH% variable. + +:tmploop +set tmpfile="%tmp%\lf.%random%.tmp" +if exist %tmpfile% goto:tmploop +lf -last-dir-path=%tmpfile% %* +if not exist %tmpfile% exit +set /p dir=<%tmpfile% +del /f %tmpfile% +if not exist "%dir%" exit +if "%dir%" == "%cd%" exit +cd /d "%dir%" diff --git a/.local/bin/passfind b/.local/bin/passfind @@ -1,21 +0,0 @@ -#!/bin/sh - -# Adapted from https://gist.github.com/heywoodlh/4c1e27f477a896bc3b0f6d55e2748d26 - -## Assumes that the user is using otp plugin -## Install fzf and make sure pass is configured beforehand - -## If you want to grab the totp code, use like so: `pass-fzf.sh otp`, otherwise script will assume you want password - -type="${1}" - -PASS_DIR=${XDG_DATA_HOME}/pass -selection="$(find -L ${PASS_DIR} -name '*.gpg' -exec realpath --relative-to=${PASS_DIR} {} | sed -e 's/.gpg//' | fzf --layout=reverse)" - -if [ "${type}" == "otp" ] -then - pass otp show "${selection}" -else - pass show "${selection}" -fi - diff --git a/.local/share/vim/pack/general/start/mru b/.local/share/vim/pack/general/start/mru @@ -0,0 +1 @@ +Subproject commit 8e8220a005d070dbd01caae86e3139d83fc444c4