From 80adf828d041fd30c2bfb584b2a1b12c53ad1a5a Mon Sep 17 00:00:00 2001 From: Jonas Gunz Date: Fri, 2 Dec 2022 00:29:52 +0100 Subject: bash --- bash/00-color.bash | 44 ++++++++++++++++++++ bash/10-alias.bash | 37 +++++++++++++++++ bash/10-board.bash | 101 ++++++++++++++++++++++++++++++++++++++++++++++ bash/10-env.profile | 30 ++++++++++++++ bash/10-fzf.bash | 11 +++++ bash/10-git.bash | 8 ++++ bash/10-prompt.bash | 35 ++++++++++++++++ bash/10-spotify.bash | 3 ++ bash/10-spotify.profile | 9 +++++ bash/10-ssh-agent.bash | 30 ++++++++++++++ bash/10-ssh-agent.profile | 9 +++++ bash/10-vim-plugins.bash | 77 +++++++++++++++++++++++++++++++++++ bash/99-wm.profile | 5 +++ bash/alias.bash | 37 ----------------- bash/board.bash | 101 ---------------------------------------------- bash/color.bash | 44 -------------------- bash/env.profile | 30 -------------- bash/fzf.bash | 11 ----- bash/git.bash | 8 ---- bash/prompt.bash | 35 ---------------- bash/spotify.bash | 3 -- bash/spotify.profile | 9 ----- bash/ssh-agent.bash | 30 -------------- bash/ssh-agent.profile | 9 ----- bash/vim-plugins.bash | 77 ----------------------------------- 25 files changed, 399 insertions(+), 394 deletions(-) create mode 100644 bash/00-color.bash create mode 100644 bash/10-alias.bash create mode 100644 bash/10-board.bash create mode 100644 bash/10-env.profile create mode 100644 bash/10-fzf.bash create mode 100644 bash/10-git.bash create mode 100644 bash/10-prompt.bash create mode 100644 bash/10-spotify.bash create mode 100644 bash/10-spotify.profile create mode 100644 bash/10-ssh-agent.bash create mode 100644 bash/10-ssh-agent.profile create mode 100644 bash/10-vim-plugins.bash create mode 100644 bash/99-wm.profile delete mode 100644 bash/alias.bash delete mode 100644 bash/board.bash delete mode 100644 bash/color.bash delete mode 100644 bash/env.profile delete mode 100644 bash/fzf.bash delete mode 100644 bash/git.bash delete mode 100644 bash/prompt.bash delete mode 100644 bash/spotify.bash delete mode 100644 bash/spotify.profile delete mode 100644 bash/ssh-agent.bash delete mode 100644 bash/ssh-agent.profile delete mode 100644 bash/vim-plugins.bash diff --git a/bash/00-color.bash b/bash/00-color.bash new file mode 100644 index 0000000..0ec938d --- /dev/null +++ b/bash/00-color.bash @@ -0,0 +1,44 @@ +# vi:syntax=sh + +black="\[\e[0;30m\]" +red="\[\e[0;31m\]" +green="\[\e[0;32m\]" +yellow="\[\e[0;33m\]" +blue="\[\e[0;34m\]" +purple="\[\e[0;35m\]" +cyan="\[\e[0;36m\]" +white="\[\e[0;37m\]" #This is actually gray +orange="\[\e[0;91m\]" + +bold_black="\[\e[30;1m\]" +bold_red="\[\e[31;1m\]" +bold_green="\[\e[32;1m\]" +bold_yellow="\[\e[33;1m\]" +bold_blue="\[\e[34;1m\]" +bold_purple="\[\e[35;1m\]" +bold_cyan="\[\e[36;1m\]" +bold_white="\[\e[37;1m\]" +bold_orange="\[\e[91;1m\]" + +underline_black="\[\e[30;4m\]" +underline_red="\[\e[31;4m\]" +underline_green="\[\e[32;4m\]" +underline_yellow="\[\e[33;4m\]" +underline_blue="\[\e[34;4m\]" +underline_purple="\[\e[35;4m\]" +underline_cyan="\[\e[36;4m\]" +underline_white="\[\e[37;4m\]" +underline_orange="\[\e[91;4m\]" + +background_black="\[\e[40m\]" +background_red="\[\e[41m\]" +background_green="\[\e[42m\]" +background_yellow="\[\e[43m\]" +background_blue="\[\e[44m\]" +background_purple="\[\e[45m\]" +background_cyan="\[\e[46m\]" +background_white="\[\e[47;1m\]" +background_orange="\[\e[101m\]" + +normal="\[\e[0m\]" +reset_color="\[\e[39m\]" diff --git a/bash/10-alias.bash b/bash/10-alias.bash new file mode 100644 index 0000000..b0bd97d --- /dev/null +++ b/bash/10-alias.bash @@ -0,0 +1,37 @@ +# vi:syntax=sh + +function back() { cd "$OLDPWD"; } + +function cs() { + cd "$@" || return $? + ls --color=auto +} + +alias ls="ls --color" +alias la="ls -a" +alias ll="ls -lh" +alias lla="ls -lha" + +if which nvim > /dev/null 2>&1 && [ ! "$FORCE_VANILLA_VIM" = "yes" ] ; then + alias vim="nvim" +fi + +# Termite compat +alias ssh="TERM=xterm-color ssh" + +alias gradle="./gradlew" + +alias gitls="git status --short ." + +alias reload="source \$HOME/.bashrc" + +alias pip-upgrade-venv="pip freeze | cut -d'=' -f1 | xargs -n1 pip install -U" + +alias vybld='docker pull vyos/vyos-build:equuleus && docker run --rm -it \ + -v "$(pwd)":/vyos \ + -v "$HOME/.gitconfig":/etc/gitconfig \ + -v "$HOME/.bash_aliases":/home/vyos_bld/.bash_aliases \ + -v "$HOME/.bashrc":/home/vyos_bld/.bashrc \ + -w /vyos --privileged --sysctl net.ipv6.conf.lo.disable_ipv6=0 \ + -e GOSU_UID=$(id -u) -e GOSU_GID=$(id -g) \ + vyos/vyos-build:equuleus bash' diff --git a/bash/10-board.bash b/bash/10-board.bash new file mode 100644 index 0000000..67c7da7 --- /dev/null +++ b/bash/10-board.bash @@ -0,0 +1,101 @@ +#!/bin/bash + +# config in ~/.files.config + +if [ ! "$BB_ENABLE" = "yes" ]; then + return +fi + +[ ! -d "$BB_HIST_DIR" ] && mkdir -p "$BB_HIST_DIR" + +# Public var, not config +BB_SHORTCUT=() + +# format +# NUM EPOCH PATH + +# add ssh targets + +function cd { + local BB_PWD + local BB_GREP_RET + local BB_NUM BB_DATE BB_DIR + + builtin cd "$@" || return $? + [ -f "$BB_DIR/history" ] || touch "$BB_HIST_DIR/history" + BB_PWD="$(pwd)" + + [ "${BB_PWD%%/}" = "${HOME%%/}" ] && return + + BB_GREP_RET=$(grep -P "^\d+ \d+ \Q$BB_PWD\E$" "$BB_HIST_DIR/history") + read -r BB_NUM BB_DATE BB_DIR <<< "$BB_GREP_RET" + if [ -n "$BB_NUM" ]; then + BB_NUM=$((BB_NUM+1)) + perl -p -i -e "s|^\d+ \d+ \Q$BB_PWD\E$|$BB_NUM $(date +%s) $BB_PWD|g" \ + "$BB_HIST_DIR/history" + else + echo "1 $(date +%s) $BB_PWD" >> "$BB_HIST_DIR/history" + fi +} + +function bashboard { + local BB_NUM BB_DATE BB_DIR + local line + local cnt + + [ -f "$BB_HIST_DIR/history" ] || return + + BB_SHORTCUT=() + + cnt=0 + while read -r line; do + local DIR BNAME DNAME + read -r BB_NUM BB_DATE BB_DIR <<< "$line" + + DIR="${BB_DIR##"$HOME"}" + DIR="${DIR##"/"}" + BNAME="$(basename "$DIR")" + DNAME="$(dirname "$DIR")" + + if [ "$DNAME" = "." ]; then + DNAME="" + else + DNAME="$DNAME/" + fi + + printf "[$cnt] $DNAME$BB_COLOR_HIGHLIGHT$BNAME$BB_COLOR_RESET\n" + + BB_SHORTCUT+=("$BB_DIR") + + cnt=$((cnt+1)) + done <<< "$(sort -nr "$BB_HIST_DIR/history" | head -n $BB_LIST_LEN)" + + # TODO recently used +} + +function bb { + if [ $# -eq 0 ]; then + bashboard + return + fi + + cd "${BB_SHORTCUT[$1]}" || return +} + +function bb_prune { + # Older than... + # Folder exists? + # shorten list + local COUNT FILEDATE FILEPATH COMP + COMP=$(date -d "-${BB_PRUNE_DAYS}days" +%s) + + echo -n > "$BB_HIST_DIR/history.new" + + while read -r COUNT FILEDATE FILEPATH; do + [ $FILEDATE -ge $COMP ] && echo "$COUNT $FILEDATE $FILEPATH" >> "$BB_HIST_DIR/history.new" + done < "$BB_HIST_DIR/history" + + mv "$BB_HIST_DIR/history.new" "$BB_HIST_DIR/history" +} + +bashboard diff --git a/bash/10-env.profile b/bash/10-env.profile new file mode 100644 index 0000000..d7e09b9 --- /dev/null +++ b/bash/10-env.profile @@ -0,0 +1,30 @@ +# vi:filetype=sh + +function appendpath() { + local regex="[:^]${1//'/'/'\/'}[:$]" + if [[ ! ${PATH} =~ $regex ]]; then + PATH=$PATH:$1 + fi +} + +appendpath "$HOME/bin" +appendpath "$DOTFILEBASE/scripts" +appendpath "$HOME/.local/bin" +appendpath "$HOME/go/bin" +appendpath "$HOME/.cabal/bin" +appendpath "$HOME/.ghcup/bin" + +export PATH +unset appendpath + +if which nvim > /dev/null 2>&1 && [ ! "$FORCE_VANILLA_VIM" = "yes" ] ; then + export EDITOR=nvim +else + export EDITOR=vim +fi + +#Java Gradle hopme PATH +export GRADLE_USER_HOME=~/.gradle + +export HISTTIMEFORMAT="%y-%m-%d %T " +export HISTSIZE=1000 diff --git a/bash/10-fzf.bash b/bash/10-fzf.bash new file mode 100644 index 0000000..76e3dde --- /dev/null +++ b/bash/10-fzf.bash @@ -0,0 +1,11 @@ +# vi:syntax=sh + +if [ -f /usr/share/fzf/completion.bash ]; then + source /usr/share/fzf/completion.bash +fi + +if [ -f /usr/share/fzf/key-bindings.bash ]; then + source /usr/share/fzf/key-bindings.bash +fi + +export FZF_COMPLETION_TRIGGER='++' diff --git a/bash/10-git.bash b/bash/10-git.bash new file mode 100644 index 0000000..365eac2 --- /dev/null +++ b/bash/10-git.bash @@ -0,0 +1,8 @@ +# vi:syntax=sh + +function get_git_state () { + local GIT_STATUS=$(git status -bs) + local GIT_BRANCH=$(echo $GIT_STATUS | grep "^## :") + local GIT_CHANGED=$(echo $GIT_STATUS | grep -c "^ M") + local GIT_UNTRACKED=$(echo $GIT_STATUS | grep -c "^??") +} diff --git a/bash/10-prompt.bash b/bash/10-prompt.bash new file mode 100644 index 0000000..ab3b977 --- /dev/null +++ b/bash/10-prompt.bash @@ -0,0 +1,35 @@ +# vi:syntax=sh + +function prompt_command () { + local EXIT="$?" + local REMOTE="" + local VENV="" + local EXECTIME="" + + local NOW=$(date +%s) + + [ $EXIT -eq 0 ] && EXIT="" + [ ! -z "$SSH_CONNECTION" ] && REMOTE="${orange}[R] " + [ -z "$VIRTUAL_ENV" ] || VENV="$(basename "$VIRTUAL_ENV")" + + if [ -n "$__LAST_PROMPT" ]; then + EXECTIME=" ($(( NOW - __LAST_PROMPT ))s)" + fi + + PS1="\n${yellow}\t${EXECTIME}${reset_color}\n${REMOTE}${white}\u@${cyan}\h: ${reset_color} ${yellow}\w ${green}${VENV}\n${red}${EXIT} ${reset_color}→ " + __LAST_PROMPT="$(date +%s)" +} + +function preexec() { + __LAST_PROMPT="$(date +%s)" +} + +preexec_invoke_exec () { + [ -n "$COMP_LINE" ] && return # do nothing if completing + [ "$BASH_COMMAND" = "$PROMPT_COMMAND" ] && return # don't cause a preexec for $PROMPT_COMMAND + local this_command=`HISTTIMEFORMAT= history 1 | sed -e "s/^[ ]*[0-9]*[ ]*//"`; + preexec "$this_command" +} +trap 'preexec_invoke_exec' DEBUG + +PROMPT_COMMAND=prompt_command diff --git a/bash/10-spotify.bash b/bash/10-spotify.bash new file mode 100644 index 0000000..1593727 --- /dev/null +++ b/bash/10-spotify.bash @@ -0,0 +1,3 @@ +#!/bin/bash + +[ -n "$SPOTIFY_SINK" ] && alias spotify="PULSE_SINK=$SPOTIFY_SINK spotify" diff --git a/bash/10-spotify.profile b/bash/10-spotify.profile new file mode 100644 index 0000000..33d0938 --- /dev/null +++ b/bash/10-spotify.profile @@ -0,0 +1,9 @@ +#!/bin/bash + +SPOTIFY_OUTPUT_REGEX="BurrBrown" + +while read -r NUM NAME REST; do + [[ "$NAME" =~ $SPOTIFY_OUTPUT_REGEX ]] && SPOTIFY_SINK=$NUM +done <<< "$(pactl list short sinks)" + +export SPOTIFY_SINK diff --git a/bash/10-ssh-agent.bash b/bash/10-ssh-agent.bash new file mode 100644 index 0000000..401564b --- /dev/null +++ b/bash/10-ssh-agent.bash @@ -0,0 +1,30 @@ +# vi: ft=sh + +#SA_SSH_AGENT_STATIC='no' +#SA_SSH_SOCKET="/var/run/user/$UID/ssh-agent.sock" +#SA_SSH_PIDFILE="/var/run/user/$UID/ssh-agent.pid" + +# For use with graphical logins when DEs don't provide an agent +# Flatpak versions of KeePassXC don't allow file access to /var/run. Allow with: +# $ flatpak override org.keepassxc.KeePassXC --user --filesystem=/run/user/$UID/ssh-agent.sock +# Caution: /var/run symlinks to /run. Flatpak for some reason does not resolve symlinks. + +if [ "$SA_SSH_AGENT_STATIC" = "yes" ]; then + AGENT_PID='' + if [ -e "$SA_SSH_PIDFILE" ]; then + AGENT_PID=$(cat $SA_SSH_PIDFILE) + fi + + if [ -z "$AGENT_PID" ] || ! kill -s 0 $AGENT_PID > /dev/null 2>&1; then + echo "Agent not running. creating one." + eval $(ssh-agent -s -a $SA_SSH_SOCKET) + + echo "PID: $SSH_AGENT_PID" + echo "$SSH_AGENT_PID" > "$SA_SSH_PIDFILE" + else + echo "Using existing Agent" + export SSH_AUTH_SOCK="$SA_SSH_SOCKET" + fi +fi + +unset AGENT_PID diff --git a/bash/10-ssh-agent.profile b/bash/10-ssh-agent.profile new file mode 100644 index 0000000..0fc4082 --- /dev/null +++ b/bash/10-ssh-agent.profile @@ -0,0 +1,9 @@ +# vi: ft=sh + +#SA_SSH_AGENT_STATIC='no' +#SA_SSH_SOCKET="/var/run/user/$UID/ssh-agent.sock" +#SA_SSH_PIDFILE="/var/run/user/$UID/ssh-agent.pid" + +if [ ! "$SA_SSH_AGENT_STATIC" = "yes" ]; then + [ -z $SSH_AUTH_SOCK ] && eval `ssh-agent` +fi diff --git a/bash/10-vim-plugins.bash b/bash/10-vim-plugins.bash new file mode 100644 index 0000000..53c927d --- /dev/null +++ b/bash/10-vim-plugins.bash @@ -0,0 +1,77 @@ +function vim-add() { + source ~/.files + + local NAME=$(basename "$1") + + [ -d "$DOTFILEBASE/.vim/bundle-active" ] || mkdir "$DOTFILEBASE/.vim/bundle-active" + [ -d "$DOTFILEBASE/.vim/bundle/$NAME" ] || return 1 # no such plugin + [ -L "$DOTFILEBASE/.vim/bundle-active/$NAME" ] && return 2 # Already exists + + local OLD_PWD=$(pwd) + cd "$DOTFILEBASE/.vim/bundle-active/" + + ln -s "../bundle/$NAME" + + cd "$OLD_PWD" +} + +function vim-remove { + source ~/.files + + local NAME=$(basename "$1") + + [ -L "$DOTFILEBASE/.vim/bundle-active/$NAME" ] || exit 1 + rm "$DOTFILEBASE/.vim/bundle-active/$NAME" +} + +# 1: git clone url +function vim-install { + source ~/.files + + test $# -eq 1 || exit 1 + + echo "Installing $1" + + ( + cd "$DOTFILEBASE/.vim/bundle" || exit 1 + git submodule add "$1" || exit 2 + git commit -m "Added vim plugin module $1" + ) +} + +function _vim_plugins { + source ~/.files + local cur prev opts plugin + + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + opts="" + + for plugin in $DOTFILEBASE/.vim/bundle/*/; do + opts+=" $(basename $plugin)" + done + + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + return 0 +} + +function _vim_plugins_active { + source ~/.files + local cur prev opts plugin + + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + opts="" + + for plugin in $DOTFILEBASE/.vim/bundle-active/*/; do + opts+=" $(basename $plugin)" + done + + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + return 0 +} + +complete -F _vim_plugins vim-add +complete -F _vim_plugins_active vim-remove diff --git a/bash/99-wm.profile b/bash/99-wm.profile new file mode 100644 index 0000000..72ecc02 --- /dev/null +++ b/bash/99-wm.profile @@ -0,0 +1,5 @@ +# vi: ft=sh + +if [ "$WM_AUTO_START" = "yes" ] && [ -z $DISPLAY ] && [ "$(tty)" = "$WM_TTY" ]; then + exec "$WM_WM" +fi diff --git a/bash/alias.bash b/bash/alias.bash deleted file mode 100644 index b0bd97d..0000000 --- a/bash/alias.bash +++ /dev/null @@ -1,37 +0,0 @@ -# vi:syntax=sh - -function back() { cd "$OLDPWD"; } - -function cs() { - cd "$@" || return $? - ls --color=auto -} - -alias ls="ls --color" -alias la="ls -a" -alias ll="ls -lh" -alias lla="ls -lha" - -if which nvim > /dev/null 2>&1 && [ ! "$FORCE_VANILLA_VIM" = "yes" ] ; then - alias vim="nvim" -fi - -# Termite compat -alias ssh="TERM=xterm-color ssh" - -alias gradle="./gradlew" - -alias gitls="git status --short ." - -alias reload="source \$HOME/.bashrc" - -alias pip-upgrade-venv="pip freeze | cut -d'=' -f1 | xargs -n1 pip install -U" - -alias vybld='docker pull vyos/vyos-build:equuleus && docker run --rm -it \ - -v "$(pwd)":/vyos \ - -v "$HOME/.gitconfig":/etc/gitconfig \ - -v "$HOME/.bash_aliases":/home/vyos_bld/.bash_aliases \ - -v "$HOME/.bashrc":/home/vyos_bld/.bashrc \ - -w /vyos --privileged --sysctl net.ipv6.conf.lo.disable_ipv6=0 \ - -e GOSU_UID=$(id -u) -e GOSU_GID=$(id -g) \ - vyos/vyos-build:equuleus bash' diff --git a/bash/board.bash b/bash/board.bash deleted file mode 100644 index 67c7da7..0000000 --- a/bash/board.bash +++ /dev/null @@ -1,101 +0,0 @@ -#!/bin/bash - -# config in ~/.files.config - -if [ ! "$BB_ENABLE" = "yes" ]; then - return -fi - -[ ! -d "$BB_HIST_DIR" ] && mkdir -p "$BB_HIST_DIR" - -# Public var, not config -BB_SHORTCUT=() - -# format -# NUM EPOCH PATH - -# add ssh targets - -function cd { - local BB_PWD - local BB_GREP_RET - local BB_NUM BB_DATE BB_DIR - - builtin cd "$@" || return $? - [ -f "$BB_DIR/history" ] || touch "$BB_HIST_DIR/history" - BB_PWD="$(pwd)" - - [ "${BB_PWD%%/}" = "${HOME%%/}" ] && return - - BB_GREP_RET=$(grep -P "^\d+ \d+ \Q$BB_PWD\E$" "$BB_HIST_DIR/history") - read -r BB_NUM BB_DATE BB_DIR <<< "$BB_GREP_RET" - if [ -n "$BB_NUM" ]; then - BB_NUM=$((BB_NUM+1)) - perl -p -i -e "s|^\d+ \d+ \Q$BB_PWD\E$|$BB_NUM $(date +%s) $BB_PWD|g" \ - "$BB_HIST_DIR/history" - else - echo "1 $(date +%s) $BB_PWD" >> "$BB_HIST_DIR/history" - fi -} - -function bashboard { - local BB_NUM BB_DATE BB_DIR - local line - local cnt - - [ -f "$BB_HIST_DIR/history" ] || return - - BB_SHORTCUT=() - - cnt=0 - while read -r line; do - local DIR BNAME DNAME - read -r BB_NUM BB_DATE BB_DIR <<< "$line" - - DIR="${BB_DIR##"$HOME"}" - DIR="${DIR##"/"}" - BNAME="$(basename "$DIR")" - DNAME="$(dirname "$DIR")" - - if [ "$DNAME" = "." ]; then - DNAME="" - else - DNAME="$DNAME/" - fi - - printf "[$cnt] $DNAME$BB_COLOR_HIGHLIGHT$BNAME$BB_COLOR_RESET\n" - - BB_SHORTCUT+=("$BB_DIR") - - cnt=$((cnt+1)) - done <<< "$(sort -nr "$BB_HIST_DIR/history" | head -n $BB_LIST_LEN)" - - # TODO recently used -} - -function bb { - if [ $# -eq 0 ]; then - bashboard - return - fi - - cd "${BB_SHORTCUT[$1]}" || return -} - -function bb_prune { - # Older than... - # Folder exists? - # shorten list - local COUNT FILEDATE FILEPATH COMP - COMP=$(date -d "-${BB_PRUNE_DAYS}days" +%s) - - echo -n > "$BB_HIST_DIR/history.new" - - while read -r COUNT FILEDATE FILEPATH; do - [ $FILEDATE -ge $COMP ] && echo "$COUNT $FILEDATE $FILEPATH" >> "$BB_HIST_DIR/history.new" - done < "$BB_HIST_DIR/history" - - mv "$BB_HIST_DIR/history.new" "$BB_HIST_DIR/history" -} - -bashboard diff --git a/bash/color.bash b/bash/color.bash deleted file mode 100644 index 0ec938d..0000000 --- a/bash/color.bash +++ /dev/null @@ -1,44 +0,0 @@ -# vi:syntax=sh - -black="\[\e[0;30m\]" -red="\[\e[0;31m\]" -green="\[\e[0;32m\]" -yellow="\[\e[0;33m\]" -blue="\[\e[0;34m\]" -purple="\[\e[0;35m\]" -cyan="\[\e[0;36m\]" -white="\[\e[0;37m\]" #This is actually gray -orange="\[\e[0;91m\]" - -bold_black="\[\e[30;1m\]" -bold_red="\[\e[31;1m\]" -bold_green="\[\e[32;1m\]" -bold_yellow="\[\e[33;1m\]" -bold_blue="\[\e[34;1m\]" -bold_purple="\[\e[35;1m\]" -bold_cyan="\[\e[36;1m\]" -bold_white="\[\e[37;1m\]" -bold_orange="\[\e[91;1m\]" - -underline_black="\[\e[30;4m\]" -underline_red="\[\e[31;4m\]" -underline_green="\[\e[32;4m\]" -underline_yellow="\[\e[33;4m\]" -underline_blue="\[\e[34;4m\]" -underline_purple="\[\e[35;4m\]" -underline_cyan="\[\e[36;4m\]" -underline_white="\[\e[37;4m\]" -underline_orange="\[\e[91;4m\]" - -background_black="\[\e[40m\]" -background_red="\[\e[41m\]" -background_green="\[\e[42m\]" -background_yellow="\[\e[43m\]" -background_blue="\[\e[44m\]" -background_purple="\[\e[45m\]" -background_cyan="\[\e[46m\]" -background_white="\[\e[47;1m\]" -background_orange="\[\e[101m\]" - -normal="\[\e[0m\]" -reset_color="\[\e[39m\]" diff --git a/bash/env.profile b/bash/env.profile deleted file mode 100644 index d7e09b9..0000000 --- a/bash/env.profile +++ /dev/null @@ -1,30 +0,0 @@ -# vi:filetype=sh - -function appendpath() { - local regex="[:^]${1//'/'/'\/'}[:$]" - if [[ ! ${PATH} =~ $regex ]]; then - PATH=$PATH:$1 - fi -} - -appendpath "$HOME/bin" -appendpath "$DOTFILEBASE/scripts" -appendpath "$HOME/.local/bin" -appendpath "$HOME/go/bin" -appendpath "$HOME/.cabal/bin" -appendpath "$HOME/.ghcup/bin" - -export PATH -unset appendpath - -if which nvim > /dev/null 2>&1 && [ ! "$FORCE_VANILLA_VIM" = "yes" ] ; then - export EDITOR=nvim -else - export EDITOR=vim -fi - -#Java Gradle hopme PATH -export GRADLE_USER_HOME=~/.gradle - -export HISTTIMEFORMAT="%y-%m-%d %T " -export HISTSIZE=1000 diff --git a/bash/fzf.bash b/bash/fzf.bash deleted file mode 100644 index 76e3dde..0000000 --- a/bash/fzf.bash +++ /dev/null @@ -1,11 +0,0 @@ -# vi:syntax=sh - -if [ -f /usr/share/fzf/completion.bash ]; then - source /usr/share/fzf/completion.bash -fi - -if [ -f /usr/share/fzf/key-bindings.bash ]; then - source /usr/share/fzf/key-bindings.bash -fi - -export FZF_COMPLETION_TRIGGER='++' diff --git a/bash/git.bash b/bash/git.bash deleted file mode 100644 index 365eac2..0000000 --- a/bash/git.bash +++ /dev/null @@ -1,8 +0,0 @@ -# vi:syntax=sh - -function get_git_state () { - local GIT_STATUS=$(git status -bs) - local GIT_BRANCH=$(echo $GIT_STATUS | grep "^## :") - local GIT_CHANGED=$(echo $GIT_STATUS | grep -c "^ M") - local GIT_UNTRACKED=$(echo $GIT_STATUS | grep -c "^??") -} diff --git a/bash/prompt.bash b/bash/prompt.bash deleted file mode 100644 index ab3b977..0000000 --- a/bash/prompt.bash +++ /dev/null @@ -1,35 +0,0 @@ -# vi:syntax=sh - -function prompt_command () { - local EXIT="$?" - local REMOTE="" - local VENV="" - local EXECTIME="" - - local NOW=$(date +%s) - - [ $EXIT -eq 0 ] && EXIT="" - [ ! -z "$SSH_CONNECTION" ] && REMOTE="${orange}[R] " - [ -z "$VIRTUAL_ENV" ] || VENV="$(basename "$VIRTUAL_ENV")" - - if [ -n "$__LAST_PROMPT" ]; then - EXECTIME=" ($(( NOW - __LAST_PROMPT ))s)" - fi - - PS1="\n${yellow}\t${EXECTIME}${reset_color}\n${REMOTE}${white}\u@${cyan}\h: ${reset_color} ${yellow}\w ${green}${VENV}\n${red}${EXIT} ${reset_color}→ " - __LAST_PROMPT="$(date +%s)" -} - -function preexec() { - __LAST_PROMPT="$(date +%s)" -} - -preexec_invoke_exec () { - [ -n "$COMP_LINE" ] && return # do nothing if completing - [ "$BASH_COMMAND" = "$PROMPT_COMMAND" ] && return # don't cause a preexec for $PROMPT_COMMAND - local this_command=`HISTTIMEFORMAT= history 1 | sed -e "s/^[ ]*[0-9]*[ ]*//"`; - preexec "$this_command" -} -trap 'preexec_invoke_exec' DEBUG - -PROMPT_COMMAND=prompt_command diff --git a/bash/spotify.bash b/bash/spotify.bash deleted file mode 100644 index 1593727..0000000 --- a/bash/spotify.bash +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -[ -n "$SPOTIFY_SINK" ] && alias spotify="PULSE_SINK=$SPOTIFY_SINK spotify" diff --git a/bash/spotify.profile b/bash/spotify.profile deleted file mode 100644 index 33d0938..0000000 --- a/bash/spotify.profile +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -SPOTIFY_OUTPUT_REGEX="BurrBrown" - -while read -r NUM NAME REST; do - [[ "$NAME" =~ $SPOTIFY_OUTPUT_REGEX ]] && SPOTIFY_SINK=$NUM -done <<< "$(pactl list short sinks)" - -export SPOTIFY_SINK diff --git a/bash/ssh-agent.bash b/bash/ssh-agent.bash deleted file mode 100644 index 401564b..0000000 --- a/bash/ssh-agent.bash +++ /dev/null @@ -1,30 +0,0 @@ -# vi: ft=sh - -#SA_SSH_AGENT_STATIC='no' -#SA_SSH_SOCKET="/var/run/user/$UID/ssh-agent.sock" -#SA_SSH_PIDFILE="/var/run/user/$UID/ssh-agent.pid" - -# For use with graphical logins when DEs don't provide an agent -# Flatpak versions of KeePassXC don't allow file access to /var/run. Allow with: -# $ flatpak override org.keepassxc.KeePassXC --user --filesystem=/run/user/$UID/ssh-agent.sock -# Caution: /var/run symlinks to /run. Flatpak for some reason does not resolve symlinks. - -if [ "$SA_SSH_AGENT_STATIC" = "yes" ]; then - AGENT_PID='' - if [ -e "$SA_SSH_PIDFILE" ]; then - AGENT_PID=$(cat $SA_SSH_PIDFILE) - fi - - if [ -z "$AGENT_PID" ] || ! kill -s 0 $AGENT_PID > /dev/null 2>&1; then - echo "Agent not running. creating one." - eval $(ssh-agent -s -a $SA_SSH_SOCKET) - - echo "PID: $SSH_AGENT_PID" - echo "$SSH_AGENT_PID" > "$SA_SSH_PIDFILE" - else - echo "Using existing Agent" - export SSH_AUTH_SOCK="$SA_SSH_SOCKET" - fi -fi - -unset AGENT_PID diff --git a/bash/ssh-agent.profile b/bash/ssh-agent.profile deleted file mode 100644 index 0fc4082..0000000 --- a/bash/ssh-agent.profile +++ /dev/null @@ -1,9 +0,0 @@ -# vi: ft=sh - -#SA_SSH_AGENT_STATIC='no' -#SA_SSH_SOCKET="/var/run/user/$UID/ssh-agent.sock" -#SA_SSH_PIDFILE="/var/run/user/$UID/ssh-agent.pid" - -if [ ! "$SA_SSH_AGENT_STATIC" = "yes" ]; then - [ -z $SSH_AUTH_SOCK ] && eval `ssh-agent` -fi diff --git a/bash/vim-plugins.bash b/bash/vim-plugins.bash deleted file mode 100644 index 53c927d..0000000 --- a/bash/vim-plugins.bash +++ /dev/null @@ -1,77 +0,0 @@ -function vim-add() { - source ~/.files - - local NAME=$(basename "$1") - - [ -d "$DOTFILEBASE/.vim/bundle-active" ] || mkdir "$DOTFILEBASE/.vim/bundle-active" - [ -d "$DOTFILEBASE/.vim/bundle/$NAME" ] || return 1 # no such plugin - [ -L "$DOTFILEBASE/.vim/bundle-active/$NAME" ] && return 2 # Already exists - - local OLD_PWD=$(pwd) - cd "$DOTFILEBASE/.vim/bundle-active/" - - ln -s "../bundle/$NAME" - - cd "$OLD_PWD" -} - -function vim-remove { - source ~/.files - - local NAME=$(basename "$1") - - [ -L "$DOTFILEBASE/.vim/bundle-active/$NAME" ] || exit 1 - rm "$DOTFILEBASE/.vim/bundle-active/$NAME" -} - -# 1: git clone url -function vim-install { - source ~/.files - - test $# -eq 1 || exit 1 - - echo "Installing $1" - - ( - cd "$DOTFILEBASE/.vim/bundle" || exit 1 - git submodule add "$1" || exit 2 - git commit -m "Added vim plugin module $1" - ) -} - -function _vim_plugins { - source ~/.files - local cur prev opts plugin - - COMPREPLY=() - cur="${COMP_WORDS[COMP_CWORD]}" - prev="${COMP_WORDS[COMP_CWORD-1]}" - opts="" - - for plugin in $DOTFILEBASE/.vim/bundle/*/; do - opts+=" $(basename $plugin)" - done - - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) - return 0 -} - -function _vim_plugins_active { - source ~/.files - local cur prev opts plugin - - COMPREPLY=() - cur="${COMP_WORDS[COMP_CWORD]}" - prev="${COMP_WORDS[COMP_CWORD-1]}" - opts="" - - for plugin in $DOTFILEBASE/.vim/bundle-active/*/; do - opts+=" $(basename $plugin)" - done - - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) - return 0 -} - -complete -F _vim_plugins vim-add -complete -F _vim_plugins_active vim-remove -- cgit v1.2.3