diff options
| author | Mitchell Riedstra <mitch@riedstra.dev> | 2021-11-02 18:15:46 -0400 |
|---|---|---|
| committer | Mitchell Riedstra <mitch@riedstra.dev> | 2021-11-02 18:15:46 -0400 |
| commit | 7881579ca687bc1214570def986e86ae738f0f26 (patch) | |
| tree | 04bfadcc7a593559f453094cb8cc64a12513fb33 /kshrc | |
| parent | b1ca7065dda47ce2efef3a7dd56c9d643c670df0 (diff) | |
| download | dotfiles-7881579ca687bc1214570def986e86ae738f0f26.tar.gz dotfiles-7881579ca687bc1214570def986e86ae738f0f26.tar.xz | |
Clean up PATH additions. Aliases.
Diffstat (limited to 'kshrc')
| -rw-r--r-- | kshrc | 47 |
1 files changed, 34 insertions, 13 deletions
@@ -17,25 +17,34 @@ alias lt="ls -tF"; alias ll="ls -lhF"; alias llt="ls -tlhF"; alias g="grep"; +alias gi="grep -i"; alias m="more"; alias j="jobs"; alias p="pwd"; alias c="column" alias ct="column -t" alias eg='grep -E' +alias egi='grep -Ei' alias egv='grep -Ev' +alias egiv='grep -Eiv' alias search='grep -niRIE' alias rot13="tr 'A-Za-z' 'N-ZA-Mn-za-m'" alias setxkbmap-list="man xkeyboard-config" # docker-getip $container_id -alias docker-getip="docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}'" +[ -x "$(command -v docker)" ] && \ + alias docker-getip="docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}'" alias xa='xargs -I{}' -alias gdb='gdb -q' -alias python='/usr/bin/env python3 -q' -alias ncmpc='ncmpc -C -M' +[ -z "$(command -v gdb)" ] && \ + alias gdb='gdb -q' +#shellcheck disable=SC2139 +[ -x "$(command -v python3)" ] && \ + alias python="$(command -v python3) -q" +[ -x "$(command -v ncmpc)" ] && \ + alias ncmpc='ncmpc -C -M' # Fun fact, Gnucash doesn't play nice when built against musl as a libc... # go figure -alias gnucash_locale_fix='export LC_ALL=C; unset LANGUAGE; gnucash' +[ -x "$(command -v gnucash)" ] && \ + alias gnucash_locale_fix='export LC_ALL=C; unset LANGUAGE; gnucash' if [ "$(uname)" = "OpenBSD" ] ; then sockstat() { @@ -105,7 +114,8 @@ setsudoaliases() { _sudo="$_doas" fi - _cmds="apt-get + _cmds="apt +apt-get apt-file yum dnf @@ -141,13 +151,11 @@ umount" # set_go set_go() { export GOPATH="${GOPATH:-$HOME/go}" - export PATH="$GOPATH/bin:$PATH" + path_preappend "$GOPATH/bin" GOROOT="${GOROOT:-/usr/local/go}" _gobin="${GOROOT}/bin" - if [ -e "$_gobin" ] && ! echo "$PATH" | grep -q "$_gobin" ; then - export PATH="$_gobin:$PATH" - fi + path_preappend "$_gobin" } _set_editor() { @@ -215,6 +223,20 @@ else fi } +# Add a given path to the start of your $PATH if it doesn't already +# exist +path_preappend() { + if [ -z "$1" ] ; then echo "need something to preappend" ; return ; fi + pth="$1"; shift + if ! echo "$PATH" | grep -qF "$pth" ; then + export PATH="$pth:$PATH" + fi +} + +path_list() { + echo "$PATH" | tr ':' '\n' +} + set_nocaps() { setxkbmap -layout "us,de" setxkbmap -option ctrl:nocaps @@ -644,9 +666,8 @@ case "$TERM" in *256color) COLOR=1;; esac -if ! echo "$PATH" | grep -q "$HOME/bin" ; then - export PATH="$HOME/bin:$PATH" -fi + +path_preappend "$HOME/bin" UPDATE_URL="https://git.riedstra.dev/mitch/dotfiles/plain/" VIM_GIT_URL="https://git.riedstra.dev/mitch/vim-cfg" |
