1
0
mirror of https://github.com/frebib/dotfiles.git synced 2024-06-14 12:57:23 +00:00

profile: add progexists function, deduplicating which

This commit is contained in:
Joe Groocock 2018-03-29 11:15:56 +01:00
parent 5a6795c8e3
commit c2dc82c1cc
Signed by: frebib
GPG Key ID: E0B16BEACFBB6A86
3 changed files with 26 additions and 21 deletions

View File

@ -22,21 +22,25 @@ export _JAVA_OPTIONS="-Dawt.useSystemAAFontSettings=on -Dswing.defaultlaf=com.su
export QT_QPA_PLATFORMTHEME=gtk2
export GOPATH="$HOME/.cache/go"
exists() { which $@ 0<&- 1>/dev/null 2>/dev/null; }
export LESS="-RNI"
export PAGER="less $LESS"
export LESS_TERMCAP_mb=$(tput bold; tput setaf 2) # green
export LESS_TERMCAP_md=$(tput bold; tput setaf 6) # cyan
export LESS_TERMCAP_me=$(tput sgr0)
export LESS_TERMCAP_so=$(tput bold; tput setaf 4) # blue
export LESS_TERMCAP_se=$(tput rmso; tput sgr0)
export LESS_TERMCAP_us=$(tput smul; tput bold; tput setaf 7) # white
export LESS_TERMCAP_ue=$(tput rmul; tput sgr0)
export LESS_TERMCAP_mr=$(tput rev)
export LESS_TERMCAP_mh=$(tput dim)
export LESS_TERMCAP_ZN=$(tput ssubm)
export LESS_TERMCAP_ZV=$(tput rsubm)
export LESS_TERMCAP_ZO=$(tput ssupm)
export LESS_TERMCAP_ZW=$(tput rsupm)
if exists tput; then
export LESS_TERMCAP_mb=$(tput bold; tput setaf 2) # green
export LESS_TERMCAP_md=$(tput bold; tput setaf 6) # cyan
export LESS_TERMCAP_me=$(tput sgr0)
export LESS_TERMCAP_so=$(tput bold; tput setaf 4) # blue
export LESS_TERMCAP_se=$(tput rmso; tput sgr0)
export LESS_TERMCAP_us=$(tput smul; tput bold; tput setaf 7) # white
export LESS_TERMCAP_ue=$(tput rmul; tput sgr0)
export LESS_TERMCAP_mr=$(tput rev)
export LESS_TERMCAP_mh=$(tput dim)
export LESS_TERMCAP_ZN=$(tput ssubm)
export LESS_TERMCAP_ZV=$(tput rsubm)
export LESS_TERMCAP_ZO=$(tput ssupm)
export LESS_TERMCAP_ZW=$(tput rsupm)
fi
# Source secret keys and values into environment
if [ -f "$CONFIG_DIR/secrets" ]; then
@ -46,17 +50,17 @@ if [ -f "$CONFIG_DIR/secrets" ]; then
fi
# Merge system clipboards
if [ -n "$DISPLAY" ] && which autocutsel >/dev/null 2>&1; then
if [ -n "$DISPLAY" ] && exists autocutsel; then
autocutsel -fork
autocutsel -selection PRIMARY -fork
fi
if [ -z "$DBUS_SESSION_BUS_ADDRESS" ] && which dbus-launch >/dev/null 2>&1; then
if [ -z "$DBUS_SESSION_BUS_ADDRESS" ] && exists dbus-launch; then
eval $(dbus-launch --sh-syntax --exit-with-session)
dbus-update-activation-environment --systemd DISPLAY
fi
# Start the gnome-keyring if it's installed
if which gnome-keyring-daemon >/dev/null 2>&1; then
if exists gnome-keyring-daemon; then
export $(/usr/bin/gnome-keyring-daemon --start --components=pkcs11,secrets,ssh,gnupg)
fi

9
.zshrc
View File

@ -13,8 +13,10 @@ HISTFILE="$ZSH_DIR/histfile"
HISTSIZE=999999
SAVEHIST=999999
exists() { which $@ 0<&- 1>/dev/null 2>/dev/null; }
# Only set tty if running interactively
if tty -s; then
if exists tty && tty -s; then
# Resolve at shell runtime
export GPG_TTY="$(tty)"
fi
@ -23,13 +25,12 @@ fi
setopt sharehistory histignorealldups histignorespace histreduceblanks
setopt pathdirs autocd autopushd extendedglob alwaystoend dvorak
# Completion initialisation
autoload -U compinit ; compinit
autoload -U bashcompinit ; bashcompinit
# gopass completion
if gopass --help &>/dev/null; then
if exists gopass; then
source <(gopass completion bash)
fi
@ -44,7 +45,7 @@ zstyle ':compinstall' filename "$HOME/.zshrc"
# Load antigen & plugins
antigen_src="$ZSH_DIR/antigen.zsh"
if [ ! -f "$antigen_src" ]; then
if which curl &>/dev/null; then
if exists curl; then
getcmd='curl -L'
else
getcmd='wget -qO-'

View File

@ -61,7 +61,7 @@ alias ssh="ssh -tt"
alias grip='grip --user=frebib --pass=$GRIP_API_KEY'
alias acme.sh='acme.sh --home $XDG_CONFIG_HOME/acme.sh --config-home $XDG_CONFIG_HOME/acme.sh --log $XDG_CONFIG_HOME/acme.sh/acme.sh.log'
alias acmesh='acme.sh --home $XDG_CONFIG_HOME/acme.sh --config-home $XDG_CONFIG_HOME/acme.sh --log $XDG_CONFIG_HOME/acme.sh/acme.sh.log'
which gopass 1>/dev/null 2>/dev/null && alias pass='gopass'
exists gopass && alias pass='gopass'
alias abuild='docker run -ti --rm \
-e USER \
-e PWD \