diff options
Diffstat (limited to '.config/shell')
-rw-r--r-- | .config/shell/env | 16 | ||||
-rw-r--r-- | .config/shell/functions.d/bwu | 29 | ||||
-rw-r--r-- | .config/shell/functions.d/venv | 48 | ||||
-rw-r--r-- | .config/shell/sources | 54 | ||||
m--------- | .config/shell/vendor/bash/feature-auto-completion | 0 | ||||
m--------- | .config/shell/vendor/zsh/feature-syntax-highlighting | 0 |
6 files changed, 113 insertions, 34 deletions
diff --git a/.config/shell/env b/.config/shell/env index de2c044..fe1e814 100644 --- a/.config/shell/env +++ b/.config/shell/env @@ -34,12 +34,14 @@ fi export DMENU_OPTS='-i -fn "Liberation Mono:pixelsize=13" -nb "#000" -nf "#fff" -sb "#4c679a" -l 15 -dim 0.5 -o 0.9' # Set XDG directories -export XDG_DATA_HOME="${HOME}/.local/share" -export XDG_CONFIG_HOME="${HOME}/.config" -export XDG_DATA_DIRS="/usr/local/share/:/usr/share/" +export XDG_CACHE_HOME="$HOME/.cache" +export XDG_CONFIG_HOME="$HOME/.config" +export XDG_DATA_HOME="$HOME/.local/share" +export XDG_STATE_HOME="$HOME/.local/state" + export XDG_CONFIG_DIRS="/etc/xdg/" -export XDG_CACHE_HOME="${HOME}/.cache" -export XDG_TEMPLATES_DIR="${HOME}/.local/templates" +export XDG_DATA_DIRS="/usr/local/share/:/usr/share/" +export XDG_TEMPLATES_DIR="$HOME/.local/templates" #export XDG_RUNTIME_DIR="" # export gpg-agent @@ -63,6 +65,10 @@ export PERL_MM_OPT="INSTALL_BASE=/home/tyil/.local" # Raku export RAKU_LOG_CLASS="Log::Colored" +# Debian maintainer variables +export DEBEMAIL="p.spek+debian@tyil.nl" +export DEBFULLNAME="Patrick Spek" + # ls colors export LS_COLORS="di=34" # directories export LS_COLORS="${LS_COLORS}:fi=0" # files diff --git a/.config/shell/functions.d/bwu b/.config/shell/functions.d/bwu new file mode 100644 index 0000000..78c1378 --- /dev/null +++ b/.config/shell/functions.d/bwu @@ -0,0 +1,29 @@ +#!/bin/sh + +bwu() { + bwu_sessionfile="/tmp/bw-session-$USER" + + if [ ! -f "$bwu_sessionfile" ] + then + # Create session file with very strict permissions + bwu_sessiondir="$(dirname "$bwu_sessionfile")" + + if [ ! -d "$bwu_sessiondir" ] + then + mkdir -p -- "$(dirname "$bwu_sessionfile")" + chmod -- 0700 "$(dirname "$bwu_sessionfile")" + fi + + touch -- "$bwu_sessionfile" + chmod -- 0600 "$bwu_sessionfile" + + # Actually get a session token + bw unlock --raw > "$bwu_sessionfile" + fi + + BW_SESSION="$(cat "$bwu_sessionfile")" + export BW_SESSION + + unset bwu_sessionfile + unset bwu_sessiondir +} diff --git a/.config/shell/functions.d/venv b/.config/shell/functions.d/venv new file mode 100644 index 0000000..c23a02d --- /dev/null +++ b/.config/shell/functions.d/venv @@ -0,0 +1,48 @@ +#!/bin/sh + +venv() { + if ! command -V "venv_$1" | grep -q " function " + then + cat <<EOF +Usage: + venv on + venv off + +Manage the python venv for a given project or directory. + +Commands: + on Enable the venv for \$PWD + off Deactivate the current venv +EOF + + return 1 + fi + + "venv_$1" +} + +venv_on() { + export PYTHON_VENV_DIR="$PWD/.venv" + export VIRTUAL_ENV_DISABLE_PROMPT=1 + + if [ ! -d "$PYTHON_VENV_DIR" ] + then + printf "Initializing venv directory at %s\n" "$PYTHON_VENV_DIR" + python3 -m venv "$PYTHON_VENV_DIR" + fi + + . "$PYTHON_VENV_DIR/bin/activate" +} + +venv_off() { + if [ -z "$PYTHON_VENV_DIR" ] + then + printf "No venv active?\n" + return 1 + fi + + deactivate + + unset PYTHON_VENV_DIR + unset VIRTUAL_ENV_DISABLE_PROMPT +} diff --git a/.config/shell/sources b/.config/shell/sources index ba19ac9..62a7f7b 100644 --- a/.config/shell/sources +++ b/.config/shell/sources @@ -2,40 +2,23 @@ # Author: Patrick Spek <p.spek@tyil.nl> # License: BSD 3-clause license # -# Apparently tmux likes to unset your PATH variable. As a workaround the PATH -# will be unset completely at the start of this script, then reset using this -# script. This was the only viable method for me to keep my PATH clean -[ "${DEBUG_DOTFILES}" ] && echo "Unsetting PATH" -unset PATH - [ "${DEBUG_DOTFILES}" ] && echo "Setting PATH" # User-local bin dir -PATH="${HOME}/.local/bin" - -# Personal scripts and wrappers -PATH="${PATH}:${HOME}/.config/shell/wrappers.d" - -# Language specific package manager bin dirs -PATH="${PATH}:${HOME}/.local/share/perl6/site/bin" -PATH="${PATH}:${HOME}/.local/share/perl6/vendor/bin" -PATH="${PATH}:${HOME}/.local/share/perl6" -PATH="${PATH}:${HOME}/.cabal/bin" - -# System bin dirs -PATH="${PATH}:/bin" -PATH="${PATH}:/sbin" -PATH="${PATH}:/usr/bin" -PATH="${PATH}:/usr/sbin" -PATH="${PATH}:/usr/local/bin" -PATH="${PATH}:/usr/local/sbin" -PATH="${PATH}:/usr/games/bin" -PATH="${PATH}:/opt/bin" +PATH="$HOME/.config/shell/wrappers.d:$PATH" +PATH="$HOME/.local/bin:$PATH" + +# snaps were a terrible idea and anyone in favour of them should be ashamed +# of themselves +if [ -d "/snap/bin" ] +then + PATH="$PATH:/snap/bin" +fi # Raku stuff if [ -d "$HOME/.raku/bin" ] then - PATH="$HOME/.raku/bin" + PATH="$PATH:$HOME/.raku/bin" fi if [ -d "/usr/local/share/perl6" ] @@ -44,6 +27,13 @@ then PATH="$PATH:/usr/local/share/perl6/vendor/bin" fi +# Python packages +if command -v python >/dev/null 2>&1 +then + PATH="$PATH:$(python -c 'import site; print(":".join(map(lambda x: x + "/usr/bin", site.getsitepackages())))')" + PATH="$PATH:$(python -c 'import site; print(":".join(map(lambda x: x + "/usr/sbin", site.getsitepackages())))')" +fi + # Load color definitions if they exist if [ -f "$HOME/.config/shell/colors/$SHORTSHELL" ] then @@ -109,7 +99,13 @@ MANPATH="/home/tyil/.local/share/man/:$MANPATH" . "$HOME/.config/shell/aliases" # Add custom functions -#. "$HOME/.config/shell/functions" +[ "${DEBUG_DOTFILES}" ] && echo " Sourcing functions.d" + +for f in "$HOME/.config/shell/functions.d"/* +do + [ "${DEBUG_DOTFILES}" ] && echo " $f" + . "$f" +done # Load profile if [ -f "${HOME}/.config/shell/profile" ] @@ -128,4 +124,4 @@ if [ -f "${HOME}/.config/shell/motd" ]; then fi # clear terminal -#[ "$DEBUG_DOTFILES" ] || clear +[ "$DEBUG_DOTFILES" ] || clear diff --git a/.config/shell/vendor/bash/feature-auto-completion b/.config/shell/vendor/bash/feature-auto-completion new file mode 160000 +Subproject a18a07b34b37377bb523afa78899259f21d575a diff --git a/.config/shell/vendor/zsh/feature-syntax-highlighting b/.config/shell/vendor/zsh/feature-syntax-highlighting new file mode 160000 +Subproject e0165eaa730dd0fa321a6a6de74f092fe87630b |