diff --git a/shell/bashrc b/shell/bashrc index c17bb28..02e7902 100644 --- a/shell/bashrc +++ b/shell/bashrc @@ -32,43 +32,7 @@ set -o vi git_branch() { GIT_BRANCH="$(git branch 2>/dev/null | sed '/\*/!d;s/^\*\s*//g;s/\s*$//g')" - [ -n "$GIT_BRANCH" ] && printf " %s " "$GIT_BRANCH" -} - -padding() { - text="$@" - len="${#text}" - tput cuf 1 - tput cub "$((len - 1))" - printf '%s' "$text" - tput cub "$len" -} - -short_time() { - TIME="$(date)" - TIME="${TIME% CST*}" - TIME="${TIME% [AP]M*}" - TIME="${TIME##* }" - TIME="${TIME%:[0-9]*}" - printf '%s' "$TIME" -} - -short_path() { - curr_path="$(pwd | sed 's/\/data\/data\/com.termux\/files\/home/~/g;s/\/home\/[A-Za-z]*/~/g')" - if [ "${#curr_path}" -gt 10 ] ; then - curr_path="${curr_path##*/}" - if git rev-parse --is-inside-work-tree >/dev/null 2>&1 ; then - curr_proj="$(git rev-parse --show-toplevel 2>/dev/null)" - curr_proj="${curr_proj##*/}" - if [ "$curr_proj" ] && [ "$curr_path" != "$curr_proj" ] ; then - [ -d "../../$curr_proj/$curr_path" ] && - curr_path="$curr_proj/$curr_path" || - curr_path="$curr_proj/⋯/$curr_path" - fi - fi - curr_path="⋯/$curr_path" - fi - printf '%s' "$curr_path" + [ -n "$GIT_BRANCH" ] && printf "%s " "$GIT_BRANCH" } [ -e "/data/data/com.termux" ] && HOSTNAME="" @@ -76,19 +40,11 @@ short_path() { [ "${HOSTNAME:=$(hostname -s)}" = "desktop" ] && HOSTNAME="󰇅" PS1=' -$(tput setaf 240)╭─$(tput setaf 7)$(tput setab 7)$(tput setaf 238)$?\ -$(tput setaf 7)$(tput setab 108)\ -$(tput setaf 235)$(tput setab 108) \ -${HOSTNAME} \ -$(tput setaf 108)$(tput setab 66) \ -$(tput setab 66)$(tput setaf 235)$(short_path) $(tput sgr0)\ -$(tput setaf 66)\ -$(tput sgr0)$(tput cr)$(tput cuf $(tput cols))\ -$(tput setaf 236)$(padding " ")$(tput setab 236)$(tput setaf 240)$(padding " $(short_time) ")$(tput sgr0)\ -$(tput bold)$(tput setab 236)$(tput setaf 5)$(padding " $(git_branch)")$(tput sgr0)\ -$(tput setaf 236)$(tput sgr0) -$(tput setaf 240)╰─\$$(tput sgr0) \ -' +\[\e[48;5;7m\] \[\e[38;5;240m\]\[\e[48;5;7m\]$?\[\e[38;5;7m\]\[\e[48;5;108m\]\ +\[\e[38;5;235m\]\[\e[48;5;108m\] ${HOSTNAME} \[\e[38;5;108m\]\[\e[48;5;66m\]\ +\[\e[48;5;66m\]\[\e[38;5;235m\] \W \[\e[45;0m\]\[\e[38;5;66m\]\ +\[\e[38;5;240m\] \@ \[\e[1;38;5;5m\]$(git_branch)\[\e[48;0m\] +\[\e[38;5;240m\] ╰─\$\[\e[0m\] ' alias \ wget="wget --hsts-file=$XDG_DATA_HOME/wget/wget-hsts" diff --git a/shell/env b/shell/env index 0a6705c..1dc66e7 100644 --- a/shell/env +++ b/shell/env @@ -24,6 +24,8 @@ export \ WGETRC="$HOME/.config/wget/wgetrc" \ GNUPGHOME="$XDG_DATA_HOME/gnupg" \ GOPATH="$XDG_DATA_HOME/go" \ + +alias wget="wget --hsts-file=$XDG_DATA_HOME/wget/wget-hsts" export \ HISTCONTROL=ignoreboth \ @@ -47,4 +49,3 @@ export \ GITLAB="ssh://git@gitlab.com/tavo-wasd" \ BOOKMARKS="$HOME/Documents/bookmarks" \ BIB="$HOME/Documents/bibliography" \ - diff --git a/shell/shellrc.org b/shell/shellrc.org new file mode 100644 index 0000000..2e8e022 --- /dev/null +++ b/shell/shellrc.org @@ -0,0 +1,149 @@ +#+title: Tavo's rc file +#+property: header-args :tangle bashrc + +* Non-interactive + +** PATH + +#+begin_src shell +PATH="$HOME/.config/scripts/status${PATH:+:${PATH}}" +PATH="$HOME/.config/scripts/menu${PATH:+:${PATH}}" +PATH="$HOME/.config/scripts/menu/xclipmenu${PATH:+:${PATH}}" +PATH="$HOME/.config/scripts/sway${PATH:+:${PATH}}" +PATH="$HOME/.config/scripts/dwm${PATH:+:${PATH}}" +PATH="$HOME/.config/wrappers${PATH:+:${PATH}}" +PATH="$HOME/.config/scripts${PATH:+:${PATH}}" +PATH="$HOME/.local/bin${PATH:+:${PATH}}" +#PATH="/usr/local/plan9/bin${PATH:+:${PATH}}" +#+end_src + +** Environment + +#+begin_src shell +export \ + GITLAB="ssh://git@gitlab.com/tavo-wasd" \ + BOOKMARKS="$HOME/Documents/bookmarks" \ + BIB="$HOME/Documents/bibliography" \ + +[ -f ~/.config/shell/env ] && . ~/.config/shell/env +#+end_src + +* Interactive + +#+begin_src shell +case $- in + *i*) ;; + *) return;; +esac +#+end_src + +** Bash-only config + +#+begin_src bash +if ! shopt -oq posix; then + for comp in /usr/share/bash-completion/bash_completion /etc/bash_completion; do + [ -f $comp ] && . $comp && break + done +fi + +bind "set completion-ignore-case on" +shopt -s checkwinsize +shopt -s histappend +complete -cf doas +shopt -s cdspell +shopt -s autocd +set -o vi +#+end_src + +** Prompt + +#+begin_src shell +git_branch() { + GIT_BRANCH="$(git branch 2>/dev/null | sed '/\*/!d;s/^\*\s*//g;s/\s*$//g')" + [ -n "$GIT_BRANCH" ] && printf "%s " "$GIT_BRANCH" +} + +[ -e "/data/data/com.termux" ] && HOSTNAME="" +[ "${HOSTNAME:=$(hostname -s)}" = "laptop" ] && HOSTNAME="󰌢" +[ "${HOSTNAME:=$(hostname -s)}" = "desktop" ] && HOSTNAME="󰇅" +#+end_src + +*** Bash-only PS1 + +#+begin_src bash +PS1=' +\[\e[48;5;7m\] \[\e[38;5;240m\]\[\e[48;5;7m\]$?\[\e[38;5;7m\]\[\e[48;5;108m\]\ +\[\e[38;5;235m\]\[\e[48;5;108m\] ${HOSTNAME} \[\e[38;5;108m\]\[\e[48;5;66m\]\ +\[\e[48;5;66m\]\[\e[38;5;235m\] \W \[\e[45;0m\]\[\e[38;5;66m\]\ +\[\e[38;5;240m\] \@ \[\e[1;38;5;5m\]$(git_branch)\[\e[48;0m\] +\[\e[38;5;240m\] ╰─\$\[\e[0m\] ' +#+end_src + +** Aliases + +#+begin_src shell +alias \ + src="cd $HOME/.local/src/ && ls" \ + cfg="cd $HOME/.config/ && ls" \ + tmp="cd $HOME/Desktop/temp/ && ls" \ + dsk="cd $HOME/Desktop/ && ls" \ + prj="cd $HOME/Desktop/projects/ && ls" \ + doc="cd $HOME/Documents/ && ls" \ + dow="cd $HOME/Downloads/ && ls" \ + mus="cd $HOME/Music/ && ls" \ + prt="cd $HOME/Pictures/Screenshots/ && ls" \ + bkg="cd $HOME/Pictures/Backgrounds/ && ls" \ + img="cd $HOME/Pictures/ && ls" \ + vid="cd $HOME/Videos/ && ls" \ + fzf="fzf --cycle --reverse" \ + diff="diff --color=auto" \ + grep="grep --color=auto" \ + calc="bc -l" \ + ls="ls -Alogh --color=auto --time-style=iso" \ + cp="cp -iv" \ + mv="mv -iv" \ + vim="nvim" \ + df-short="df -h | grep -v '\s/dev.*$\|\s/run.*$\|\s/boot.*$'" \ + qr-png="qrencode -s 16 -o qr.png" \ + qr="qrencode -t ansiutf8" \ + +if [ "${XDG_SESSION_TYPE}" = "wayland" ] ; then + alias clip="wl-copy" +fi + +if [ "${XDG_SESSION_TYPE}" = "x11" ] ; then + alias clip="xsel -ib" +fi + +! command -v sudo >/dev/null 2>&1 && alias sudo="doas" +command -v exa >/dev/null 2>&1 && alias ls="exa -al --icons --group-directories-first --no-permissions --no-user --time-style=iso --git" +command -v eza >/dev/null 2>&1 && alias ls="eza -al --icons --group-directories-first --no-permissions --no-user --time-style=iso --git" +command -v trash >/dev/null 2>&1 && alias rm="trash" +#+end_src +** Utils + +#+begin_src shell + +util_get_ssid() { + [ -e "/sbin/iw" ] && iw="/sbin/iw" + iw="${iw:=$(command -v iw)}" + [ "${iw}" ] || return 1 + int="$(sed '/:/!d;s/^ *//;s/:.*$//' /proc/net/wireless)" + if [ "$int" ] && grep 'up' /sys/class/net/w*/operstate >/dev/null 2>&1 ; then + "${iw}" "${int}" link | sed '/SSID/!d;s/^.*: //' + fi +} +#+end_src + +** Startup + +#+begin_src shell +if [ "$(tty)" = "/dev/tty1" ] ; then + sleep 0.5 + amixer & + #exec startx + exec sway +fi + +command -v fetch >/dev/null 2>&1 && fetch min +#+end_src diff --git a/vim/vimrc b/vim/vimrc index 9acc3b4..af9aeed 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -160,6 +160,7 @@ Plug 'preservim/tagbar' " Plug 'morhetz/gruvbox' Plug 'sainnhe/gruvbox-material' Plug 'jceb/vim-orgmode' +Plug 'mikelue/vim-maven-plugin' call plug#end() " gruvbox-material