dotfiles

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

commit 35daab70d247d15f16fed247277a6b9feea7d823
parent 19dc654340b5319938efd8bbe2c54469c908e3d5
Author: Bharatvaj <bharatvaj@yahoo.com>
Date:   Sat, 23 Jul 2022 16:10:40 +0530

Add .local/bin/sh for posix scripts

Add .config/vim/ftplugin/cpp.vim for cpp filetype completions in vim

Add insert mode keybindings for vim

Use Regular Fira Mono font for alacritty. SemiBold seems a little
fluffy.

Refactor scripts to use $FUZZER variable instead of hard coding the fzy
or fzf

Diffstat:
M.config/alacritty/font.yml | 13+++++++------
M.config/tmux/tmux.conf | 7++++---
M.config/user-dirs.dirs | 16++++++++--------
A.config/vim/ftplugin/cpp.vim | 10++++++++++
M.config/vim/keybindings/keybindings.vim | 15+++++++++------
M.config/vim/plugin/plugin.vim | 3+++
M.gitignore | 6+++++-
A.local/bin/sh/pfs | 10++++++++++
A.local/bin/sh/rssr | 18++++++++++++++++++
A.local/bin/sh/songdl | 11+++++++++++
A.local/bin/sh/spot | 10++++++++++
A.local/bin/sh/tmux-now-playing | 9+++++++++
M.profile | 13+++++++++++--
13 files changed, 115 insertions(+), 26 deletions(-)

diff --git a/.config/alacritty/font.yml b/.config/alacritty/font.yml @@ -1,15 +1,16 @@ font: normal: - family: Fira Code - style: SemiBold + family: Fira Mono + style: Regular bold: - family: Fira Code + family: Fira Mono style: Bold italic: - family: Fira Code - style: Italic + family: Fira Mono + style: Regular Italic bold_italic: - family: Fira Code + family: Fira Mono + style: Bold Italic diff --git a/.config/tmux/tmux.conf b/.config/tmux/tmux.conf @@ -2,11 +2,12 @@ set -g base-index 1 set escape-time 0 set -g set-titles on +bind c new-window -c "#{pane_current_path}" # Status bar set -g status-position top -set -g status-justify absolute-centre -set -g status-right "" +set -g status-justify left +set -g status-right "#(tmux-now-playing)" set -g status-keys vi bind v split-window -h bind s split-window -v @@ -40,10 +41,10 @@ bind P paste-buffer # Themes set -g status-bg black set -g status-fg white -set -g status-right "#(mpc current)" set -g window-status-current-style "bg=black,fg=red" set -g pane-active-border-style "fg=red" + # Smart pane switching with awareness of Vim splits. # See: https://github.com/christoomey/vim-tmux-navigator is_vim="ps -o state= -o comm= -t '#{pane_tty}' \ diff --git a/.config/user-dirs.dirs b/.config/user-dirs.dirs @@ -1,8 +1,8 @@ -XDG_DESKTOP_DIR="$HOME/Desktop" -XDG_DOCUMENTS_DIR="$HOME/Documents" -XDG_DOWNLOAD_DIR="$HOME/downloads" -XDG_MUSIC_DIR="$HOME/Music" -XDG_PICTURES_DIR="$HOME/Pictures" -XDG_PUBLICSHARE_DIR="$HOME/Public" -XDG_TEMPLATES_DIR="$HOME/Templates" -XDG_VIDEOS_DIR="$HOME/Videos" +XDG_DESKTOP_DIR="$XDG_DATA_HOME/desktop" +XDG_DOCUMENTS_DIR="$XDG_DATA_HOME/documents" +XDG_DOWNLOAD_DIR="$XDG_CACHE_HOME/downloads" +XDG_MUSIC_DIR="$XDG_DATA_HOME/music" +XDG_PICTURES_DIR="$XDG_DATA_HOME/pictures" +XDG_PUBLICSHARE_DIR="$XDG_DATA_HOME/public" +XDG_TEMPLATES_DIR="$XDG_DATA_HOME/templates" +XDG_VIDEOS_DIR="$XDG_DATA_HOME/videos" diff --git a/.config/vim/ftplugin/cpp.vim b/.config/vim/ftplugin/cpp.vim @@ -0,0 +1,10 @@ +augroup CppIAbbrevs + autocmd! + autocmd FileType c,cpp :iabbrev main@ int main(int argc, char* argv[]) {<cr><cr>}<up> + autocmd FileType c,cpp :iabbrev fun@ <esc>bvedivoid <C-o>P() {<cr><cr>}<up> + autocmd FileType c,cpp :iabbrev p@ printf("\n");<esc>4hi + autocmd FileType c,cpp :iabbrev r@ return;<left> + autocmd FileType c,cpp :iabbrev i@ #include <><left> + autocmd FileType c,cpp :iabbrev for@ <esc>bvedifor(int <c-o>P=0; <c-o>P < n; <c-o>P++) {<cr><cr>}<up> +augroup END + diff --git a/.config/vim/keybindings/keybindings.vim b/.config/vim/keybindings/keybindings.vim @@ -1,11 +1,11 @@ " General keybindings -nnoremap <Leader>lb :ls<CR>:b<space> +nnoremap <leader>lb :ls<CR>:b<space> nnoremap <leader>co :copen<cr> nnoremap <leader>cs :cdo<space>s/ nnoremap <leader>ec :edit $XDG_CONFIG_HOME/vim/vimrc<cr> nnoremap <leader>ek :edit $XDG_CONFIG_HOME/vim/keybindings/keybindings.vim<cr> nnoremap <leader>et :set expandtab<cr> -nnoremap <leader>f :find * +nnoremap <leader>ff :find * nnoremap <leader>lo :lopen<cr> nnoremap <leader>ls :ldo<space>s/ nnoremap <leader>p :Rg<cr> @@ -13,10 +13,13 @@ nnoremap <leader>so :source %<cr> nnoremap <leader>tt :tabnew<cr> nnoremap <leader>vg :vimgrep<space> " Buffer Creation -nnoremap <Leader>sc :source ~/.config/vim/vimrc<enter> -nnoremap <Leader>ss :split<enter> -nnoremap <Leader>vv :vsplit<enter> +nnoremap <leader>sc :source ~/.config/vim/vimrc<enter> +nnoremap <leader>ss :split<enter> +nnoremap <leader>vv :vsplit<enter> +" Accessible completions +inoremap <c-f> <c-x><c-f> +inoremap <c-l> <c-x><c-l> " Behave vim nnoremap Y y$ @@ -67,7 +70,7 @@ let g:ctrlp_map = '<tab><tab>' let g:ctrlp_user_command = ['.git/', 'git --git-dir=%s/.git ls-files -oc --exclude-standard'] let g:ctrlp_working_path_mode = 'r' let g:gutentags_file_list_command = 'rg --files' -nnoremap <leader><leader> :CtrlPTag<cr> +nnoremap <leader><leader> :CtrlPBuffer<cr> " vim-fugitive nnoremap <leader>gg :Ggrep<space> nnoremap <leader>lg :Glgrep<space> diff --git a/.config/vim/plugin/plugin.vim b/.config/vim/plugin/plugin.vim @@ -15,3 +15,6 @@ function SaveAndBuild() wall Make endfunction + +" TODO load this automatically +source $XDG_CONFIG_HOME/vim/ftplugin/cpp.vim diff --git a/.gitignore b/.gitignore @@ -17,7 +17,11 @@ # Local shell scripts !.local/ !.local/bin/ -!.local/bin/** +# !.local/bin/** +!.local/bin/cmd/ +!.local/bin/cmd/** +!.local/bin/sh/ +!.local/bin/sh/** # !.local/share/vim/pack/**/start/** # !.local/share/vim/pack/**/opt/** diff --git a/.local/bin/sh/pfs b/.local/bin/sh/pfs @@ -0,0 +1,10 @@ +#!/bin/sh + +# reliable password fuzzy searcher + +cd "${PASSWORD_STORE_DIR}" || exit 1 + +selection="$(find -L . -name '*.gpg' | sed 's/.gpg$//g' | ${FUZZER})" + +test -z "${selection}" || pass ${1} "${selection}" + diff --git a/.local/bin/sh/rssr b/.local/bin/sh/rssr @@ -0,0 +1,18 @@ +#!/bin/sh + +# rssr - rss reader + +[ -z "$RSSR_FUZZY_SEARCHER" ] && RSSR_FUZZY_SEARCHER=$(FUZZER) +[ -z "$FEEDS_PATH" ] && FEEDS_PATH="${HOME}/.sfeed/feeds" +[ -z "$BROWSER" ] && BROWSER=open + +test -z "$RSSR_FUZZY_SEARCHER" && ( echo "RSSR_FUZZY_SEARCHER needs to be set" && exit 1 ) + +cd "$FEEDS_PATH" || (echo "FEEDS_PATH: $FEEDS_PATH does not exist" && exit 1) + +website="$(ls | $RSSR_FUZZY_SEARCHER)" + +[ -n "$website" ] && link=$(cat "$website" | cut -f3 | $RSSR_FUZZY_SEARCHER) + +[ -n "$link" ] && "$BROWSER" "$link" + diff --git a/.local/bin/sh/songdl b/.local/bin/sh/songdl @@ -0,0 +1,11 @@ +#!/bin/sh + +[ $# -ne 1 ] && echo "Usage: $0 <youtube-url>" && exit 1 + +[ -z "$SONGDL_HOME" ] && SONGDL_HOME="${XDG_MUSIC_DIR}" + +cd "$SONGDL_HOME" + +song_name=$1 + +youtube-dl --external-downloader aria2c --extract-audio --audio-format mp3 "$song_name" diff --git a/.local/bin/sh/spot b/.local/bin/sh/spot @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +#TODO Check system for this variable before setting default. +#TODO Handle if program not found +#TODO Add more search dirs for different platforms +search_dirs=("/Applications" "/System/Applications") + +app="$(find ${search_dirs[@]} -maxdepth 2 -name "*.app" -type d | ${FUZZER})" + +test -n "${app}" && open "${app}" diff --git a/.local/bin/sh/tmux-now-playing b/.local/bin/sh/tmux-now-playing @@ -0,0 +1,9 @@ +#!/bin/sh + +#TODO figure out how th this is working in the first place +status=$(mpc) + +song_status="$(mpc | sed 2q | tac | head -n1)" +song_title="$(printf $status | head -n2 | tac | head -n1)" + +printf "%s - %s\n" "${song_status}" "${song_title}" diff --git a/.profile b/.profile @@ -8,6 +8,15 @@ export XDG_CONFIG_HOME="$XDG_ROOT/.config" export XDG_DATA_HOME="$XDG_ROOT/.local/share" export XDG_CACHE_HOME="$XDG_ROOT/.cache" +export XDG_DESKTOP_DIR="$XDG_DATA_HOME/desktop" +export XDG_DOCUMENTS_DIR="$XDG_DATA_HOME/documents" +export XDG_DOWNLOAD_DIR="$XDG_CACHE_HOME/downloads" +export XDG_MUSIC_DIR="$XDG_DATA_HOME/music" +export XDG_PICTURES_DIR="$XDG_DATA_HOME/pictures" +export XDG_PUBLICSHARE_DIR="$XDG_DATA_HOME/public" +export XDG_TEMPLATES_DIR="$XDG_DATA_HOME/templates" +export XDG_VIDEOS_DIR="$XDG_DATA_HOME/videos" + # Global programs export VIMINIT="if !has('nvim') source $XDG_CONFIG_HOME/vim/vimrc @@ -49,7 +58,7 @@ export VSCODE_PORTABLE="$XDG_DATA_HOME/vscode" export GRADLE_USER_HOME="$XDG_DATA_HOME"/gradle export SQLITE_HISTORY="$XDG_DATA_HOME/sqlite_history" export MYSQL_HISTFILE="$XDG_DATA_HOME/mysql_history" -# export ZDOTDIR="$XDG_DATA_HOME/zsh" +export SONGDL_HOME="${XDG_DATA_HOME}/music/" export PSQL_HISTORY="$XDG_CACHE_HOME/pg/psql_history" export NUGET_PACKAGES="$XDG_CACHE_HOME"/NuGetPackages @@ -60,7 +69,7 @@ export GEM_SPEC_CACHE="$XDG_CACHE_HOME"/gem HISTTIMEFORMAT="%F %T " # Local executables -export PATH=${PATH}:${HOME}/.local/bin:${XDG_DATA_HOME}/npm/bin:${XDG_DATA_HOME}/.cargo/bin +export PATH=${PATH}:${HOME}/.local/bin:${HOME}/.local/bin/sh:${XDG_DATA_HOME}/npm/bin:${XDG_DATA_HOME}/.cargo/bin chance() { # Hit or miss