dotfiles

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

commit 3de8f87e89cdbb9d9078dd8baf0f898631bab334
parent 8dcb32f25a92597c8c8a55e8afea26ec5f75dccd
Author: Bharatvaj <bharatvaj@yahoo.com>
Date:   Mon,  4 Jul 2022 16:15:56 +0530

Remove .config/sh/plugin

Fix gpg in windows

Add j.bat and lfcd.bat

Add lua keybindings for saving and closing

Remove unwanted script passfind

Fix gpg path issue

Diffstat:
M.config/.gitignore | 4+++-
M.config/cmd/aliases.bat | 4+---
A.config/cmd/env.bat | 15+++++++++++++++
D.config/cmd/environment.bat | 9---------
M.config/cmd/profile.cmd | 4+++-
M.config/cmd/setup.cmd | 2++
A.config/nvim/lua/keybindings.lua | 10++++++++++
M.config/sh/aliases | 1+
D.config/sh/plugin/git | 10----------
D.config/sh/plugin/index | 13-------------
D.config/sh/plugin/shorthand | 7-------
M.config/vim/keybindings/keybindings.vim | 23+++++++++++++++++------
M.gitignore | 2+-
A.local/bin/cmd/j.cmd | 16++++++++++++++++
A.local/bin/cmd/lfcd.cmd | 15+++++++++++++++
D.local/bin/passfind | 21---------------------
16 files changed, 84 insertions(+), 72 deletions(-)

diff --git a/.config/.gitignore b/.config/.gitignore @@ -9,8 +9,10 @@ !bash/** !clink !clink/clink_settings +cmd/userenv.bat +!cmd/ +# TODO specify each file individually !cmd/ -!cmd/** !git/ !git/config !i3 diff --git a/.config/cmd/aliases.bat b/.config/cmd/aliases.bat @@ -3,6 +3,4 @@ doskey vi=vim $* doskey n=nvim $* doskey g=git $* doskey e=%EDITOR% $* -doskey l=%USERPROFILE%\.config\cmd\lfcd.cmd - -set SOURCE_DEV_TOOLS="C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" +doskey l=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/environment.bat b/.config/cmd/environment.bat @@ -1,9 +0,0 @@ -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 - -set MYVIMRC=%XDG_CONFIG_HOME%\vim\vimrc -set VIMINIT=source $MYVIMRC - diff --git a/.config/cmd/profile.cmd b/.config/cmd/profile.cmd @@ -3,5 +3,7 @@ cd %USERPROFILE% prompt $P ∆ -@call %XDG_CONFIG_HOME%\cmd\environment.bat +@call %XDG_CONFIG_HOME%\cmd\env.bat +@call %XDG_CONFIG_HOME%\cmd\userenv.bat + @call %XDG_CONFIG_HOME%\cmd\aliases.bat diff --git a/.config/cmd/setup.cmd b/.config/cmd/setup.cmd @@ -11,3 +11,5 @@ IF NOT EXIST %USERPROFILE%\.config\vim\vimrc mklink %USERPROFILE%\_vimrc %USERPR 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/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 @@ -22,3 +22,4 @@ mich curl && alias gip="curl ifconfig.co" alias '?d'='sr duckduckgo' alias l=lfcd +alias x=extract_archive diff --git a/.config/sh/plugin/git b/.config/sh/plugin/git @@ -1,10 +0,0 @@ -mich git || return - -alias g='git' - -# ---------------------- -# Git Functions -# ---------------------- -# Git log find by commit message -glf() { git log --all --grep="$1"; } - diff --git a/.config/sh/plugin/index b/.config/sh/plugin/index @@ -1,13 +0,0 @@ -# Plugins should be sourced from this file -# Instead of hardcoding in bashrc file - -SH_PLUGIN_DIR="${XDG_CONFIG_HOME}/sh/plugin" - -shplug() { - PLUGIN_FILE="${SH_PLUGIN_DIR}/${1}" - chance "${PLUGIN_FILE}" -} - -shplug git -shplug nb -shplug shorthand diff --git a/.config/sh/plugin/shorthand b/.config/sh/plugin/shorthand @@ -1,7 +0,0 @@ -# Bindings for important commands - -[ -n "${EDITOR}" ] && alias e='${EDITOR}' - -alias cls=clear -mich git && alias g=git -mich pass && alias p=pass 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/.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/.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 -