dotfiles

Cross platform dotfiles for linux, mac and windows

commit 851f1f864aaa4e769f3ee5cf25a3512cb909c1ad
parent 9de1f6e4eedc7ef922d836a7a7d634b126801214
Author: Bharatvaj <bharatvaj@yahoo.com>
Date: Wed, 21 Jun 2023 09:04:34 +0530

Use extract.sh to house the extract function which

...does more than archive extracts. Added audio extract.

Moved redundant content from .config/bash/bashrc to .bash_profile
itself, very lightweight. rm -rf .config/bash and the unstaged file is
now .config/bash_unstaged

Made 'a' to work with abuco and $FUZZER. Works good enough.

'f' is now made smart. Easy to find files and cd into directories.

Properly done the VimEnter autocommand for nvim. By default nvim-dap
loads .vscode/launch.json from now on.

Remove loading mac setting in alacritty.yml. Started using Terminal.app
in mac. Easy logistics.
14 files changed, 130 insertions(+), 94 deletions(-)
M
.bash_profile
|
6
+++---
M
.config/.gitignore
|
2
--
M
.config/alacritty/alacritty.yml
|
1
-
D
.config/bash/aliases
|
4
----
D
.config/bash/bashrc
|
9
---------
D
.config/bash/plugin/shorthand
|
9
---------
M
.config/nvim/init.lua
|
30
++++++++++++++++++------------
M
.config/sh/aliases
|
11
+++++------
M
.config/sh/functions
|
88
++++++++++++++++++++++++++++++++++++++++++++-----------------------------------
M
.config/vim/keybindings.vim
|
9
+++++++--
M
.config/vim/vimrc
|
13
++++++++++++-
A
.local/bin/sh/extract.sh
|
25
+++++++++++++++++++++++++
M
.local/share/vim/plugins
|
3
+++
M
.profile
|
14
++++++++------
diff --git a/.bash_profile b/.bash_profile
@@ -1,4 +1,4 @@
-[ -n "$1" ] && XDG_ROOT="$1" || XDG_ROOT="$HOME"
-
 [ -f "${XDG_ROOT}"/.profile ] && . "${XDG_ROOT}"/.profile
-[ -f "${XDG_CONFIG_HOME}"/bash/bashrc ] && . "${XDG_CONFIG_HOME}"/bash/bashrc
+set -o vi
+PS1='\w> '
+[ -f "$XDG_CONFIG_HOME/bash_unstaged" ] && . "$XDG_CONFIG_HOME/bash_unstaged"
diff --git a/.config/.gitignore b/.config/.gitignore
@@ -8,8 +8,6 @@
 !X11/xinitrc
 !alacritty/
 !alacritty/**
-!bash/
-!bash/bashrc
 !clink
 !clink/clink_settings
 !cmd/
diff --git a/.config/alacritty/alacritty.yml b/.config/alacritty/alacritty.yml
@@ -1,5 +1,4 @@
 import:
-  - ~/.config/alacritty/mac.yml
   - ~/.config/alacritty/windows.yml
   - ~/.config/alacritty/bindings.yml
   - ~/.config/alacritty/unstaged.yml
diff --git a/.config/bash/aliases b/.config/bash/aliases
@@ -1,4 +0,0 @@
-which startx >&/dev/null && alias startx="startx \"$XDG_CONFIG_HOME/X11/xinitrc\" vt1"
-which wget >&/dev/null && alias wget="wget --hsts-file=\"$XDG_CACHE_HOME/wget-hsts\""
-which nvim >&/dev/null && alias vim="nvim" && alias vi="nvim" 
-which elinks >&/dev/null && alias elinks="elinks ddg.gg"
diff --git a/.config/bash/bashrc b/.config/bash/bashrc
@@ -1,9 +0,0 @@
-set -o vi
-
-PATH_EXPORTS=( "${ESSENTIAL_PATH_EXPORTS[@]}" "${OTHER_PATH_EXPORTS[@]}" )
-
-export PATH="${PATH}:${PATH_EXPORTS[*]}"
-
-PS1='\w> '
-
-[ -f "$XDG_CONFIG_HOME/bash/unstaged" ] && . "$XDG_CONFIG_HOME/bash/unstaged"
diff --git a/.config/bash/plugin/shorthand b/.config/bash/plugin/shorthand
@@ -1,9 +0,0 @@
-# One letter bindings for important commands
-
-[ ! -z "${EDITOR}" ] && alias e=${EDITOR}
-
-alias c=clear
-
-which git >&/dev/null && alias g=git
-
-which pass >&/dev/null & alias p=pass
diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua
@@ -28,10 +28,12 @@ g.netrw_banner = 0
 g.netrw_liststyle = 3
 
 vim.cmd([[
-" TODO use lua api
+	source $XDG_DATA_HOME/vim/hyper-red.vim
+]])
 
-function! s:load_plugins(t) abort
-	set packpath+=~/.local/share/vim
+function load_plugns()
+	vim.cmd([[
+	set packpath+=$XDG_DATA_HOME/vim
 	packadd fzf
 	packadd fzf.vim
 	packadd vim-fugitive

@@ -40,20 +42,24 @@ function! s:load_plugins(t) abort
 	packadd vim-tmux-navigator
 	packadd vim-unimpaired
 	packadd vim-xcode
+	packadd vim-dispatch
 
 	packadd nvim-dap
 	packadd nvim-dap-ui
 	packadd nvim-lspconfig
+	]])
+	require"dapui".setup()
+	require"lspconfig".clangd.setup{}
+	require"unstaged"
 
-	lua require"dapui".setup()
-	lua require"lspconfig".clangd.setup{}
-	lua require"unstaged"
-endfunction
+	require('dap').adapters.cppdbg = {
+		type = 'executable',
+		command = 'lldb-vscode',
+		name = 'cppdbg'
+	}
 
-augroup user_cmds
-	autocmd!
-	autocmd VimEnter * call timer_start(20, function('s:load_plugins'))
-augroup END
-]])
+	require('dap.ext.vscode').load_launchjs(nil, { cppdbg = {'c', 'cpp'} })
+end
 
+vim.defer_fn(function() load_plugns() end, 20)
 
diff --git a/.config/sh/aliases b/.config/sh/aliases
@@ -27,26 +27,25 @@ alias n='cd_and_ls'
 alias cf="quickopen cd d"
 alias ef="quickopen ${EDITOR} f"
 alias gf='$EDITOR $(git ls-files | ${FUZZER})'
-alias vf="quickopen ${VISUAL} f"
 # TODO make it work for linux
 alias of="quickopen open f"
 # This won't work with dash
 # dash want's alias \-
-# alias -- -='cd -'
+alias -- -='cd -'
 
 # [shorthands]
+alias a=attach
 alias '?d'='sr duckduckgo'
 alias cls=clear
 alias d='download'
 alias e='${EDITOR}'
-alias f=find_
-alias g='git'
+alias f=quickopen
 alias g=git
 alias l=lfcd
 alias le=less
-alias m=make
+alias m=smartmake
 alias v="VIMINIT='' nvim"
-alias x=extract_archive
+alias x=extract.sh
 
 # [longhands]
 alias girl='grep -irl'
diff --git a/.config/sh/functions b/.config/sh/functions
@@ -1,54 +1,66 @@
-# TODO implement [dest_dir] functionality
-# Iterate over each arguments
-# Treat last argument as dest folder? or use -d
-extract_archive () {
-	test $# -lt 1 && { printf "Usage: $0 <archive>\n"; exit 1; }
-	test -f $1 || { printf "$0: $1: No such file \n"; exit 1; }
-	lowercase_ext=$(printf "%s" "$1" | rev | cut -d '.' -f1 | tr '[:upper:]' '[:lower:]' | rev)
-	case $lowercase_ext in
-		z) 7z x "$1" ;;
-		bz2) bzip2 -d "$1" ;;
-		bz) bzip2 -d "$1" ;;
-		gz) gunzip -d "$1" ;;
-		rar) unrar x "$1" ;;
-		tar) tar -xvf "$1" ;;
-		tgz) tar -zxvf "$1" ;;
-		zip) unzip "$1" ;;
-	*) printf "'$1' Error. Unsupported filetype.\n" >&2 ;;
-	esac
-}
-
 md() {
 	mkdir "$@" && cd "$@"
 }
 
+attach() {
+	if there abduco && [ $# -eq 0 ]; then
+		sesh_name=$(abduco -l | tail -n +2 | cut -f3 | $FUZZER)
+		abduco -a $sesh_name || {
+			echo "Do you want to create session: $sesh_name? (press any key)";
+			read a && abduco -c $sesh_name mtm;
+		}
+	fi
+	[ $# -gt 0 ] && abduco -a $1
+}
+
 # TODO make it non-interruptable
 insult() {
-	if type sl 1>/dev/null; then
-		sl
-	else
-		printf "You are a noob for typing '$1'\n"
+	if there sl; then
+		sl else printf "You are a noob for typing '$1'\n"
 		sleep 5
 	fi
 }
 
+smartmake() {
+    if there fmake && there errorformat; then
+        $(fmake) $* | errorformat
+    else
+        make
+    fi
+}
+
 thwart() {
-	alias $1="insult '$1'"
+    alias $1="insult '$1'"
 }
 
 quickopen() {
-	if ! type "${FUZZER}" 2>/dev/null; then
+	if ! there "${FUZZER}"; then
 		printf '${FUZZER} not available\n'
+		exit 1
+	fi
+
+	# TODO maybe add -type in the future TODO add $name
+	#if [ $# -gt 0 ]; then
+	#	name="-name $@"
+	#fi
+	# 2>/dev/null
+	if if [ -d .git ]; then
+		optional_files="$(git ls-files) |"
+		somethin="$(git ls-files | ${FUZZER})"
+	else maxdepth=${1:-3} somethin="$(find .  -maxdepth $maxdepth | ${FUZZER})" fi
+	if [ -z "$somethin" ]; then
+		return;
+	elif [ -f "$somethin" ]; then
+		$EDITOR "$somethin"
+	elif [ -d "$somethin" ]; then
+		cd "$somethin"
 	else
-		test "$#" -lt 1 && print "usage: $0 <command> [find -type]"
-		test -z "$2" && 2=f
-		${1} "$(find . -type $2 -maxdepth 3 2>/dev/null | ${FUZZER})"
+		printf '%s: is neither a file nor a directory\n' "$somethin"
+		exit 1
 	fi
 }
 
-cd_and_ls() {
-		cd $* && ls
-}
+cd_and_ls() { cd $* && ls }
 
 download() {
 	# TODO use wget if curl not available

@@ -59,14 +71,12 @@ find_() {
 	find . -name "*$**"
 }
 
-vim_plug() {
-	export VIM_PLUGINS_DIR="$XDG_DATA_HOME"/vim/pack/voom/opt
-	export VIM_DIR="$XDG_DATA_HOME"/vim
-	voom $@
+vim_plug() { export
+	VIM_PLUGINS_DIR="$XDG_DATA_HOME"/vim/pack/voom/opt export
+	VIM_DIR="$XDG_DATA_HOME"/vim voom $@
 }
 
 nvim_plug() {
-	export VIM_PLUGINS_DIR="$XDG_DATA_HOME"/nvim/pack/voom/opt
-	export VIM_DIR="$XDG_DATA_HOME"/nvim
-	voom $@
+    export VIM_PLUGINS_DIR="$XDG_DATA_HOME"/nvim/pack/voom/opt
+    export VIM_DIR="$XDG_DATA_HOME"/nvim voom $@
 }
diff --git a/.config/vim/keybindings.vim b/.config/vim/keybindings.vim
@@ -19,6 +19,7 @@ nnoremap <leader>so :source %<cr>
 nnoremap <leader>spp :set paste<cr>
 nnoremap <leader>spa :set path+=**<cr>
 nnoremap <leader>tt :tabnew<cr>
+nnoremap <leader>ta :tab *
 nnoremap <leader>vg :vimgrep<space>
 " Buffer Creation
 nnoremap <leader>sc :source $XDG_CONFIG_HOME/vim/vimrc<cr>

@@ -44,6 +45,11 @@ nnoremap <leader>oh :grepadd /:: %
 
 nnoremap <leader>fb :b *
 
+fun! SaveAndBuild()
+    :wall
+    :Make
+endfun
+
 " quick navigation
 nnoremap \f :GFiles<cr>
 nnoremap \F :Files<cr>

@@ -86,8 +92,7 @@ nnoremap <leader>lg :Glgrep<space>
 
 
 " Generate ctags
-nnoremap<leader>gt :!sh -c "ctags `rg --files`"<CR>
-set tags+=.git/tags
+nnoremap<leader>gt :!sh -c "ctags `git --ls-files`"<CR>
 
 nnoremap <CR> :noh<CR><CR>:<backspace>
 
diff --git a/.config/vim/vimrc b/.config/vim/vimrc
@@ -7,6 +7,8 @@ else
 	endif
 endif
 
+set complete-=i
+
 " General
 set nocompatible
 set mouse=

@@ -94,8 +96,17 @@ function! s:load_plugins(t) abort
 	packadd vim-fugitive
 	packadd vim-unimpaired
 	packadd vim-better-whitespace
+	packadd notmuch-vim
+	packadd vim-dispatch
+	let g:notmuch_use_fzf = 1
+	let g:notmuch_open_command = 'fzf'
+	let g:notmuch_fzf_command = 'fzf --reverse'
+	let g:notmuch_use_conversation_view = 1
+	let sendmail_path = systemlist('sed -n "s/^set sendmail=\(.*\)$/\1/p; $!d" ~/.mailrc')
+	if len(sendmail_path) > 0
+		let g:notmuch_sendmail=sendmail_path[0]
+	endif
 endfunction
-
 augroup user_cmds
 	autocmd!
 	autocmd VimEnter * call timer_start(20, function('s:load_plugins'))
diff --git a/.local/bin/sh/extract.sh b/.local/bin/sh/extract.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+# TODO implement [dest_dir] functionality
+# Currently extracts to the current directory
+# Iterate over each arguments
+# Treat last argument as dest folder? or use -d
+# Allow extraction of multple archives in the order
+test $# -lt 1 && { printf "Usage: $(basename $0) <archive>\n"; exit 1; }
+test -f $1 || { printf "$0: $1: No such file \n"; exit 1; }
+case $1 in
+    *.z) 7z x "$1" ;;
+    *.bz2) bzip2 -d "$1" ;;
+    *.bz) bzip2 -d "$1" ;;
+    *.gz) gunzip -d "$1" ;;
+    *.rar) unrar x "$1" ;;
+    *.tar) tar -xvf "$1" ;;
+    *.tar.gz) tar -xvf "$1" ;;
+    *.tgz) tar -zxvf "$1" ;;
+    *.zip) unzip "$1" ;;
+    *.mp4)
+        audio_codec=$(ffprobe -show_streams -select_streams a "$1" | grep codec_name | cut -f2 -d "=")
+        ffmpeg -i "$1" -c:a copy $(basename $1).${audio_codec}
+        ;;
+
+*) printf "'$1' Error. Unsupported filetype.\n" >&2 ;;
+esac
diff --git a/.local/share/vim/plugins b/.local/share/vim/plugins
@@ -23,7 +23,10 @@ tpope/vim-unimpaired
 tpope/vim-vinegar
 tpope/vim-vinegar
 vim-scripts/gitignore
+torrancew/vim-openscad
 yegappan/mru
+https://github.com/bfrg/vim-jqplay
+notmuch-vim/notmuch-vim
 
 # https://git.sr.ht/~torresjrjr/birck.vim
 # rcarriga/nvim-dap-ui
diff --git a/.profile b/.profile
@@ -1,6 +1,4 @@
 #!/bin/sh
-export GREP_COLOR='1;35;40'
-
 [ -n "$1" ] && XDG_ROOT="$1" || XDG_ROOT="$HOME"
 
 # XDG

@@ -66,7 +64,7 @@ HISTTIMEFORMAT="%F %T "
 HISTCONTROL=erasedups
 
 # Local executables
-export PATH=${PATH}:${HOME}/.local/bin:${HOME}/.local/bin/sh:${XDG_DATA_HOME}/npm/bin:${XDG_DATA_HOME}/.cargo/bin:${XDG_DATA_HOME}/gem/bin
+export PATH=${PATH}:${HOME}/.local/bin:${HOME}/.local/bin/sh:${XDG_DATA_HOME}/npm/bin:${XDG_DATA_HOME}/.cargo/bin:${GOPATH}/bin:${XDG_DATA_HOME}/gem/bin
 
 chance() {
     # Hit or miss

@@ -81,10 +79,12 @@ there() {
 # Setup editor
 # TODO until I grok the shell and able to control the clipboard and
 # registers with terminal level keybings. I am not going back to vi/nvi
-export VISUAL=vim
-export EDITOR="$(there nvim && echo nvim || echo vim)"
+#alias vim=vi
+#alias nvim=vi
+export VISUAL=nvim
+export EDITOR=nvim
 there $EDITOR || unset $EDITOR
-export FUZZER="$(there sk && echo sk || echo fzf)"
+export FUZZER=fzy
 there $FUZZER || unset $FUZZER
 
 export BROWSER=lynx

@@ -101,3 +101,5 @@ export LESS_TERMCAP_se=$'\e[0m'
 export CLICOLOR=1
 export LSCOLORS="xxexcxdxbxegxdxbagxcxd"
 export LS_COLORS="di=0:ln=34:so=32:pi=33:ex=31:bd=34;46:cd=0;43:su=0;41:sg=30;46:tw=0;42:ow=0;43"
+export GREP_COLOR='1;35;40'
+