diff options
author | Patrick Spek <p.spek@tyil.nl> | 2019-10-02 16:35:18 +0200 |
---|---|---|
committer | Patrick Spek <p.spek@tyil.nl> | 2019-10-02 16:35:18 +0200 |
commit | d62f1d1673fc0a319ea4581dee0f6085b1f70005 (patch) | |
tree | 78ea262acbdf6b43ed9c7c3f18b8012867e40615 /.config/shell | |
parent | 06d7914df92c78469b84220aee5e18f2517af1dc (diff) |
Add shell configs
Diffstat (limited to '.config/shell')
-rw-r--r-- | .config/shell/aliases | 30 | ||||
-rw-r--r-- | .config/shell/aliases.d/generic | 44 | ||||
-rw-r--r-- | .config/shell/aliases.d/linux | 8 | ||||
-rw-r--r-- | .config/shell/aliases.d/linux-funtoo | 5 | ||||
-rw-r--r-- | .config/shell/env | 104 | ||||
-rw-r--r-- | .config/shell/functions.d/c | 50 | ||||
-rw-r--r-- | .config/shell/functions.d/m | 5 | ||||
-rw-r--r-- | .config/shell/functions.d/s | 6 | ||||
-rw-r--r-- | .config/shell/init | 8 | ||||
-rw-r--r-- | .config/shell/profile | 7 | ||||
-rw-r--r-- | .config/shell/sources | 105 |
11 files changed, 372 insertions, 0 deletions
diff --git a/.config/shell/aliases b/.config/shell/aliases new file mode 100644 index 0000000..bacb17d --- /dev/null +++ b/.config/shell/aliases @@ -0,0 +1,30 @@ +#!/usr/bin/env sh + +# Docker aliases +alias dc="docker-compose" +alias dcu="docker-compose up" + +# Musicplayer aliases +alias ma="mpc add" +alias mh="ncmpcpp --host" +alias mp="mpc toggle > /dev/null" + +# tmux aliases +alias t="tmux -2 -f ~/.config/tmux/conf -u" + +# Other aliases +alias :q="exit" +alias ag="ag --color-line-number '0;33' --color-match '1;31' --color-path '1;33' --smart-case" +alias bc="bc -i ~/.config/bcrc" +alias g="grep --color=always -i" +alias kubewatch="watch -n1 'kubectl get pod -o wide --all-namespaces | grep -Ev \"^kube-\"'" +alias links-g="links -g" # Termite cant deal with it if its an argument +alias p="ps -A -o pid,comm | grep -i" +alias parescan="pacmd unload-module module-udev-detect && pacmd load-module module-udev-detect" +alias rcopy="rsync --append-verify --info=ALL,PROGRESS -ar" +alias slideshow="feh -zsZ.D 5" +#!/usr/bin/env sh + +# General purpose +alias l="ls -Fhl --color=auto" +alias ll="ls -Fahl --color=auto" diff --git a/.config/shell/aliases.d/generic b/.config/shell/aliases.d/generic new file mode 100644 index 0000000..74c9cb6 --- /dev/null +++ b/.config/shell/aliases.d/generic @@ -0,0 +1,44 @@ +#!/usr/bin/env sh +# Author: Patrick Spek <p.spek@tyil.nl> +# License: BSD 3-clause license + +# this should fix sudo with aliases +alias sudo="sudo " + +# docker aliases +alias dc="docker-compose" +alias dcu="docker-compose up" + +# musicplayer aliases {{{ +alias ma="mpc add" +alias mh="ncmpcpp --host" +alias mp="mpc toggle > /dev/null" +# }}} + +# tmux aliases {{{ +alias t="tmux -2 -f ~/.config/tmux/conf -u" +# }}} + +# virsh aliases {{{ +alias v="virsh --connect qemu:///system" +alias vc="v console" +alias vl="v list --all" +alias vp="v suspend" +alias vr="v resume" +alias vs="v start" +# }}} + +# other aliases {{{ +alias :q="exit" +alias ag="ag --color-line-number '0;33' --color-match '1;31' --color-path '1;33' --smart-case" +alias bc="bc -i ~/.config/bcrc" +alias cpan6="perl6 -I ~/projects/scriptkitties/perl6-App-Cpan6/lib -I ~/projects/private/perl6-JSON-Fast/lib ~/projects/scriptkitties/perl6-App-Cpan6/bin/cpan6" +alias g="grep --color=always -i" +alias links-g="links -g" # Termite cant deal with it if its an argument +alias muttman="~/projects/rb/muttman/src/muttman" +alias p="ps -A -o pid,comm | grep -i" +alias rcopy="rsync --append-verify --info=ALL,PROGRESS -ar" +alias slideshow="feh -zsZ.D 5" +alias wifiman="wicd-curses" +alias parescan="pacmd unload-module module-udev-detect && pacmd load-module module-udev-detect" +# }}} diff --git a/.config/shell/aliases.d/linux b/.config/shell/aliases.d/linux new file mode 100644 index 0000000..a744c93 --- /dev/null +++ b/.config/shell/aliases.d/linux @@ -0,0 +1,8 @@ +#!/usr/bin/env sh +# Author: Patrick Spek <p.spek@tyil.nl> +# License: BSD 3-clause license + +# general purpose +alias l="ls -Fhl --color=auto" +alias ll="ls -Fahl --color=auto" + diff --git a/.config/shell/aliases.d/linux-funtoo b/.config/shell/aliases.d/linux-funtoo new file mode 100644 index 0000000..3c417a7 --- /dev/null +++ b/.config/shell/aliases.d/linux-funtoo @@ -0,0 +1,5 @@ +#!/usr/bin/env sh +# Author: Patrick Spek <p.spek@tyil.nl> +# License: BSD 3-clause license + +alias dist-upgrade="sudo emerge --keep-going -uDN @world" diff --git a/.config/shell/env b/.config/shell/env new file mode 100644 index 0000000..99eb1ff --- /dev/null +++ b/.config/shell/env @@ -0,0 +1,104 @@ +#!/usr/bin/env sh +# Author: Patrick Spek <p.spek@tyil.nl> +# License: BSD 3-clause license + +# Force terminal type +export TERM=screen-256color + +# Set locale +export LANG="en_US.UTF-8" +export LESSCHARSET="utf-8" + +# Set favourite applications +export EDITOR="vim" +export ALTERNATE_EDITOR="vim" + +# set homepage for w3m +export WWW_HOME=https://duckduckgo.com/ + +# set history +export HISTFILE=~/.local/var/shell/histfile && mkdir -p -- "$(dirname "${HISTFILE}")" +export HISTSIZE=10000 +export SAVEHIST=10000 + +# set dmenu rice +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_CONFIG_DIRS="/etc/xdg/" +export XDG_CACHE_HOME="${HOME}/.cache" +export XDG_TEMPLATES_DIR="${HOME}/templates" +#export XDG_RUNTIME_DIR="" + +# export gpg-agent +if [ -z "$GPG_AGENT_INFO" ]; then + eval $(gpg-agent --daemon) +fi + +# Set JAVA environment +#export _JAVA_OPTIONS="-Dawt.useSystemAAFontSettings=on -Dswing.aatext=true -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel -Dswing.crossplatformlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel" +export _JAVA_AWT_WM_NONREPARENTING=1 + +# Set GO environment +export GOPATH=~/projects/go + +# Perl cpan +export PERL5LIB="/home/tyil/.local/lib/perl5" +export PERL_MB_OPT="--install_base \"/home/tyil/.local\"" +export PERL_MM_OPT="INSTALL_BASE=/home/tyil/.local" + +# ls colors +export LS_COLORS="di=34" # directories +export LS_COLORS="${LS_COLORS}:fi=0" # files +export LS_COLORS="${LS_COLORS}:ln=35" # symlinks +export LS_COLORS="${LS_COLORS}:pi=0" # fifo file +export LS_COLORS="${LS_COLORS}:so=32" # socket files +export LS_COLORS="${LS_COLORS}:bd=33" # block devices +export LS_COLORS="${LS_COLORS}:cd=33" # character devices +export LS_COLORS="${LS_COLORS}:or=37" # orphaned symlinks +export LS_COLORS="${LS_COLORS}:mi=37" # missing file (referenced to by symlink) +export LS_COLORS="${LS_COLORS}:ex=31" # executable file + +# fix for QT5 +export QT_STYLE_OVERRIDE=GTK+ + +# Set tabsize in the TTY +#setterm -regtabs 4 +tabs -4 > /dev/null + +# note to self: remove when rtorrent becomes sane or gets replaced +# double note to self: enable whenever you consider using rtorrent again +#stty start undef +#stty stop undef + +# enable interactive comments in zsh +set -k + +### setting up the tty +# alter the colors +echo -en "\e]P0000000" #black +echo -en "\e]P1CA674A" #darkred +echo -en "\e]P26BC260" #darkgreen +echo -en "\e]P3D3A94A" #brown +echo -en "\e]P44C679A" #darkblue +echo -en "\e]P59C35AC" #darkmagenta +echo -en "\e]P66EB5F3" #darkcyan +echo -en "\e]P7A9A9A9" #lightgrey +echo -en "\e]P8535551" #darkgrey +echo -en "\e]P9EA2828" #red +echo -en "\e]PA87DD32" #green +echo -en "\e]PBFFC66D" #yellow +echo -en "\e]PC355DB0" #blue +echo -en "\e]PD9050D8" #magenta +echo -en "\e]PE32DDDD" #cyan +echo -en "\e]PFCCCCCC" #white +[ ! "$DEBUG_DOTFILES" ] && clear #for background artifacting + +# set default background and text color +#setterm -background black -foreground green -store + +# set the cursor +#export CURSOR_STYLE="\e[?6;14;9;c" diff --git a/.config/shell/functions.d/c b/.config/shell/functions.d/c new file mode 100644 index 0000000..bc1c033 --- /dev/null +++ b/.config/shell/functions.d/c @@ -0,0 +1,50 @@ +#!/usr/bin/env sh + +c() +{ + destination="$1" + + if [ -z "${SHELLSTORE}" ] + then + return 1 + fi + + store=${SHELLSTORE}/chdir_history + + # Make sure the store exists + touch "${store}" + + if [ -z "$1" ] + then + destination=$(tail -n 1 "${store}") + + if [ "${destination}" != "" ] + then + sed '$ d' "${store}" > "${store}.sed" + mv "${store}.sed" "${store}" + fi + else + dots=$(expr "${destination}" : '^\.\+$') + + if [ "$dots" -gt 2 ] + then + destination="" + + while [ "${dots}" -gt 1 ] + do + destination="${destination}../" + + dots=$((dots - 1)) + done + fi + fi + + owd=$(pwd) + + cd "${destination}" || return 2 + l + + [ ! -z "$1" ] && printf "%s\n" "${owd}" >> "${store}" + + unset destination dots store +} diff --git a/.config/shell/functions.d/m b/.config/shell/functions.d/m new file mode 100644 index 0000000..75a2095 --- /dev/null +++ b/.config/shell/functions.d/m @@ -0,0 +1,5 @@ +#!/usr/bin/env sh + +m () { + mkdir -p "$1" && c "$1" +} diff --git a/.config/shell/functions.d/s b/.config/shell/functions.d/s new file mode 100644 index 0000000..bce5780 --- /dev/null +++ b/.config/shell/functions.d/s @@ -0,0 +1,6 @@ +#!/usr/bin/env sh + +s() +{ + sed -n "$1" +} diff --git a/.config/shell/init b/.config/shell/init new file mode 100644 index 0000000..379d889 --- /dev/null +++ b/.config/shell/init @@ -0,0 +1,8 @@ +#! /usr/bin/env sh + +if [ -z "${SHELLSTORE}" ] +then + SHELLSTORE=$(mktemp -d -t "shellstore_XXXXX") + + export SHELLSTORE +fi diff --git a/.config/shell/profile b/.config/shell/profile new file mode 100644 index 0000000..f0ba63d --- /dev/null +++ b/.config/shell/profile @@ -0,0 +1,7 @@ +#! /usr/bin/env sh + +if command -v lonestar > /dev/null 2>&1 +then + [ "${DEBUG_DOTFILES}" ] && echo "Initializing LoneStar" + eval "$(lonestar init)" +fi diff --git a/.config/shell/sources b/.config/shell/sources new file mode 100644 index 0000000..c4acb5e --- /dev/null +++ b/.config/shell/sources @@ -0,0 +1,105 @@ +#!/bin/usr/env sh +# 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}/.scripts/generic" +PATH="${PATH}:${HOME}/.config/shell/wrappers.d" + +# Language specific package manager bin dirs +PATH="${PATH}:${HOME}/.perl6/bin" +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" + +# Nix package manager +if [ -f "$HOME/.nix-profile/etc/profile.d/nix.sh" ] +then + # In case of single-user Nix installation + . "$HOME/.nix-profile/etc/profile.d/nix.sh" +else + if [ -d "/nix/var/nix/profiles/per-user/${USER}" ] + then + # In case of multi-user Nix installation + PATH="${PATH}:/nix/var/nix/profiles/per-user/${USER}/profile/bin" + fi +fi + +[ "${DEBUG_DOTFILES}" ] && echo "Setting FPATH" +FPATH="${HOME}/.config/shell/completion ${FPATH}" + +[ "${DEBUG_DOTFILES}" ] && echo "Sourcing ~/.config/shell/env" +# shellcheck disable=SC1090 +. "${HOME}/.config/shell/env" + +if [ -f "${HOME}/.local/etc/shell/env" ] +then + [ "${DEBUG_DOTFILES}" ] && echo "Sourcing ~/.local/etc/shell/env" + # shellcheck disable=SC1090 + . "${HOME}/.local/etc/shell/env" +fi + +# if ruby is installed and we have a gems folder, include it in the path +if ruby -v > /dev/null 2>&1 +then + GEMDIR="$(ruby -r rubygems -e 'puts Gem.user_dir')/bin" + + if [ -d "$GEMDIR" ] + then + [ "$DEBUG_DOTFILES" ] && echo "Extending PATH with $GEMDIR" + PATH="$GEMDIR:$PATH" + fi +fi + +# Add machine-specific paths from ~/.local/etc/shell/path +if [ -f "$HOME/.local/etc/shell/path" ] +then + for p in $(envsubst < "$HOME/.local/etc/shell/path") + do + PATH="$PATH:$p" + done +fi + +# export the extended PATH +export PATH + +# Add aliases +. "$HOME/.config/shell/aliases" + +# Add custom functions +#. "$HOME/.config/shell/functions" + +# Load profile +if [ -f "${HOME}/.config/shell/profile" ] +then + [ "${DEBUG_DOTFILES}" ] && echo " Loading ~/.config/shell/init" + #shellcheck disable=1090 + . "${HOME}/.config/shell/profile" +fi + + +# show motd +if [ -f "${HOME}/.config/shell/motd" ]; then + [ "${DEBUG_DOTFILES}" ] && echo "Reading motd" + # shellcheck disable=SC1090 + . "${HOME}/.config/shell/motd" +fi |