bash: Switch to bash Signed-off-by: Anirudh Oppiliappan <x@icyphox.sh>
Anirudh Oppiliappan x@icyphox.sh
Fri, 20 Sep 2019 23:46:25 +0530
3 files changed,
139 insertions(+),
0 deletions(-)
A
bash/.bashrc
@@ -0,0 +1,50 @@
+# export thingys +export ZSH=/home/$USER/.oh-my-zsh +export BROWSER=/usr/bin/firefox +export EDITOR=/usr/bin/nvim +export SSH_KEY_PATH="~/.ssh/id_rsa" +export PATH=$HOME/bin:$PATH +export GPG_TTY=$(tty) +export INPUTRC=~/.inputrc +export PATH=$PATH:$HOME/leet/Nim/bin +export PATH=$PATH:$HOME/.nimble/bin +export PATH=$PATH:$HOME/.local/bin +export PATH=$PATH:/usr/local/go/bin + +# better history syncing +shopt -s histappend +export HISTCONTROL=ignoreboth:erasedups +HISTSIZE=1000 +HISTFILESIZE=2000 +#export PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND$'\n'}history -a; history -c; history -r" + +# cool options for cool kids +shopt -s \ + autocd \ + globstar \ + checkwinsize \ + cdspell \ + dirspell \ + expand_aliases \ + dotglob \ + gnu_errfmt \ + histreedit \ + nocasematch + +bind 'set completion-ignore-case on' +bind 'set show-all-if-ambiguous on' +bind 'set colored-stats on' +bind 'set completion-display-width 1' +bind 'TAB:menu-complete' + +if ! shopt -oq posix; then + if [ -f /usr/share/bash-completion/bash_completion ]; then + . /usr/share/bash-completion/bash_completion + elif [ -f /etc/bash_completion ]; then + . /etc/bash_completion + fi +fi + +# source aliases and prompt +source ~/.bash/aliases +source ~/.bash/prompt
A
bash/aliases
@@ -0,0 +1,48 @@
+#!/usr/bin/env bash + +alias gah='sudo $(fc -ln -1)' +alias nvime="nvim ~/.config/nvim/init.vim" +alias socks="ssh -D 8008 emerald -fN" +alias o="xdg-open" +alias gc="git commit -v -s" +alias gst="git status --short" +alias ga="git add" +alias gd="git diff --minimal" +alias gl="git log --oneline --decorate --graph" +alias ls="ls --color" +alias vim="nvim" + +function up { + ~/bin/icyup.sh "$1" +} + +function nvmon { + source ~/.nvm/nvm.sh +} + +function envac { + source .env/bin/activate +} + +function vpn { + ~/bin/vpnon.sh +} + +function f() { + fff "$@" + cd "$(cat "${XDG_CACHE_HOME:=${HOME}/.cache}/fff/.fff_d")" +} + +function git_branch() { + local git_status="$(git status 2> /dev/null)" + local on_branch="On branch ([^${IFS}]*)" + local on_commit="HEAD detached at ([^${IFS}]*)" + + if [[ $git_status =~ $on_branch ]]; then + local branch=${BASH_REMATCH[1]} + echo -ne "───${grn} $branch ${rst}" + elif [[ $git_status =~ $on_commit ]]; then + local commit=${BASH_REMATCH[1]} + echo -ne "───${ylw} $commit ${rst}" + fi +}
A
bash/prompt
@@ -0,0 +1,41 @@
+#!/usr/bin/env bash + +red="\e[31m" +grn="\e[32m" +ylw="\e[33m" +cyn="\e[36m" +blu="\e[34m" +prp="\e[35m" +bprp="\e[35;1m" +gry="\e[94m" +rst="\e[0m" + +git_branch() { + local git_status="$(git status 2> /dev/null)" + local on_branch="On branch ([^${IFS}]*)" + local on_commit="HEAD detached at ([^${IFS}]*)" + + if [[ $git_status =~ $on_branch ]]; then + local branch=${BASH_REMATCH[1]} + echo -ne " ${grn} $branch ${rst}" + elif [[ $git_status =~ $on_commit ]]; then + local commit=${BASH_REMATCH[1]} + echo -ne " ${ylw} $commit ${rst}" + fi +} + +prompt_pwd() { + path="$(echo $PWD)" + echo -ne "\001${gry}\002$path\001${rst}\002" +} + +rootornot() { + if [[ "$(id -u)" -eq 0 ]]; then + echo -ne "\001${red}\002#\001${rst}\002" + else + echo -ne "›" + fi +} + +PS1='\n$(prompt_pwd)$(git_branch)\n$(rootornot) ' +PS2="> "