dotfiles

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

commit 04470c52cda848742fa4052834e311b42c465ba4
parent f82b440acbbe4f96b0e400be41f04df99d9beda8
Author: Bharatvaj <bharatvaj@yahoo.com>
Date:   Sat, 18 Jun 2022 11:24:36 +0530

Merge remote-tracking branch 'origin/macos' into base

Diffstat:
M.config/sh/aliases | 51+++++++++++++++++++++++++++++++++------------------
A.config/sh/functions | 38++++++++++++++++++++++++++++++++++++++
D.config/sh/plugin/git | 10----------
D.config/sh/plugin/index | 13-------------
D.config/sh/plugin/shorthand | 7-------
M.profile | 16++++++++--------
6 files changed, 79 insertions(+), 56 deletions(-)

diff --git a/.config/sh/aliases b/.config/sh/aliases @@ -1,24 +1,39 @@ -mich abook && alias abook='abook --config "$XDG_CONFIG_HOME"/abook/abookrc --datafile "$XDG_DATA_HOME"/abook/addressbook' -mich startx && alias startx='startx "$XDG_CONFIG_HOME/X11/xinitrc" vt1' -mich wget && alias wget='wget --hsts-file="$XDG_CACHE_HOME/wget-hsts"' -mich mbsync && alias mbsync='mbsync -c "$XDG_CONFIG_HOME"/isync/mbsyncrc' -mich emcc && alias emcc='emcc --em-config "$XDG_CONFIG_HOME"/emscripten/config --em-cache "$XDG_CACHE_HOME"/emscripten/cache' -mich dict && alias dict='dict -c "$XDG_CONFIG_HOME"/dict/dictrc' -mich btpd && alias btpd='btpd -d "$XDG_DATA_HOME"/btpd' -mich abook && alias abook='abook -C "$XDG_CONFIG_HOME"/abook/abookrc --datafile "$XDG_DATA_HOME"/abook/addressbook' -mich vim && alias v='vim' -mich nvim && alias n='nvim' +# [xdg] +alias abook='abook --config "$XDG_CONFIG_HOME"/abook/abookrc --datafile "$XDG_DATA_HOME"/abook/addressbook' +alias abook='abook -C "$XDG_CONFIG_HOME"/abook/abookrc --datafile "$XDG_DATA_HOME"/abook/addressbook' +alias btpd='btpd -d "$XDG_DATA_HOME"/btpd' +alias dict='dict -c "$XDG_CONFIG_HOME"/dict/dictrc' +alias mbsync='mbsync -c "$XDG_CONFIG_HOME"/isync/mbsyncrc' +alias startx='startx "$XDG_CONFIG_HOME/X11/xinitrc" vt1' +alias wget='wget --hsts-file="$XDG_CACHE_HOME/wget-hsts"' -# conditioning -## ls conditioning -mich sl && alias ld='sl' && alias lls='sl' && alias llls=sl && alias sls=sl && alias lsl=sl && alias lss=sl && alias kls=sl +# [ls_conditioning] +thwart sl && thwart ld && thwart lls && thwart sls && thwart lsl && thwart lss && thwart kls +# [cd_conditioning] +thwart cdd -## cd conditioning -mich sl && alias cdd=sl +# [ip] +there ifconfig && alias lip="ifconfig | grep -w inet | cut -d ' ' -f2" +there curl && alias gip="curl ifconfig.co" -# ip -mich ifconfig && alias lip="ifconfig | grep -w inet | cut -d ' ' -f2" -mich curl && alias gip="curl ifconfig.co" +# [navigation] +alias -- -='cd -' +alias ....='cd ../../..' +alias ...='cd ../..' +alias ..='cd ..' +alias cf="quickopen cd d" +alias ef="quickopen ${EDITOR} f" +alias vf="quickopen ${VISUAL} f" +# [shorthands] alias '?d'='sr duckduckgo' +alias cls=clear +alias d='wget' +alias e='${EDITOR}' +alias f='find . -name ' +alias g='git' +alias g=git alias l=lfcd +alias n='nvim' +alias v='vim' +alias x=extract diff --git a/.config/sh/functions b/.config/sh/functions @@ -0,0 +1,38 @@ +# TODO implement [dest_dir] functionality +extract () { + 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 + *.Z) 7z x $1 ;; + *.bz2) bzip2 -d $1 ;; + *.gz) gunzip -d $1 ;; + *.rar) unrar x $1 ;; + *.tar) tar -xvf $1 ;; + *.tar.bz2) tar -jxvf $1 ;; + *.tar.gz) tar -zxvf $1 ;; + *.tgz) tar -zxvf $1 ;; + *.zip) unzip $1 ;; + *) echo "'$1' Error. Unsupported filetype." ;; + esac +} + +md() { + mkdir "$@" && cd "$@" +} + +# TODO make it non-interruptable +insult() { + printf "You are a noob for typing '$1'\n" + sleep 5 +} + +thwart() { + alias $1="insult '$1'" +} + +quickopen() { + test -z "${FUZZER}" && printf '${FUZZER} not set\n' + test "$#" -lt 1 && print "usage: $0 <command> [find -type]" + test -z "$2" && 2=f + ${1} "$(find . -type $2 -maxdepth 3 2>/dev/null | ${FUZZER})" +} 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/.profile b/.profile @@ -1,3 +1,4 @@ +#!/bin/sh export GREP_COLOR='1;35;40' # XDG @@ -25,7 +26,6 @@ export DOCKER_CONFIG="$XDG_CONFIG_HOME"/docker export INPUTRC="$XDG_CONFIG_HOME"/readline/inputrc export NOTMUCH_CONFIG="$XDG_CONFIG_HOME/notmuch/config" export NPM_CONFIG_USERCONFIG="$XDG_CONFIG_HOME/npm/npmrc" -export EM_CONFIG="$XDG_CONFIG_HOME"/emscripten/config export ELINKS_CONFDIR="$XDG_CONFIG_HOME/elinks" export FFMPEG_DATADIR="$XDG_DATA_HOME"/ffmpeg @@ -65,20 +65,20 @@ chance() { [ -f "${1}" ] && . "${1}" } -# TODO refactor function name -mich() { +there() { + # Checks the availability of an executable type "$@" >/dev/null 2>/dev/null } # Setup editor -export VISUAL=$(mich nvim && echo nvim || echo vim ) -export EDITOR="$VISUAL" +export VISUAL=vim +export EDITOR="$(there nvi && echo nvi || echo vi)" +export FUZZER=sk -export BROWSER="$(mich lynx && echo lynx)" +export BROWSER=lynx export SURFRAW_browser="$BROWSER" +chance "${XDG_CONFIG_HOME}/sh/functions" chance "${XDG_CONFIG_HOME}/sh/aliases" -chance "${XDG_CONFIG_HOME}/sh/plugin/index" chance "${XDG_CONFIG_HOME}/sh/unstaged" -