diff --git a/aliases b/aliases index 246c31e..d0099d3 100755 --- a/aliases +++ b/aliases @@ -34,21 +34,23 @@ ## Use Exa instead of ls ## REQUIRES NERD FONT -alias ls='exa --icons --group-directories-first' +has exa && alias ls='exa --icons --group-directories-first' ## Shorten xdg-open -alias xopen='xdg-open' +has xdg-open && alias xopen='xdg-open' ## cls Clear Screen run ls alias cls='clear; ls' ## Shorten scriptedit ## REQUIRES scriptedit (Script) -alias se='scriptedit' +has scriptedit && alias se='scriptedit' ## YouTube downloader -alias yt='youtube-dl' -alias yta='youtube-dl --ignore-config --add-metadata --ignore-errors --extract-audio --format "bestaudio/best"' +if has youtube-dl ; then + alias yt='youtube-dl' + alias yta='youtube-dl --ignore-config --add-metadata --ignore-errors --extract-audio --format "bestaudio/best"' +fi ## alias cp='cp --interactive --verbose' @@ -62,10 +64,10 @@ alias grep='grep --color=auto' alias ip='ip --color=auto' ## Open Vimwiki -alias vw='nvim -c VimwikiIndex' +has nvim && alias vw='nvim -c VimwikiIndex' ## Change Wineprefix quick and EZ -alias ws='source wineselect' +has wineselect && alias ws='source wineselect' ## zero a terminal session alias zero='dirs -c && clear' @@ -74,11 +76,24 @@ alias zero='dirs -c && clear' # FileType Associations # # extension=program # ######################### +if has nvim; then + VIM=nvim +elif has vim; then + VIM=vim +elif has vi; then + VIM=vi +else + VIM='' +fi -alias -s tex=nvim -alias -s html=nvim -alias -s pdf=zathura -alias -s md=nvim +if [[ -n $VIM ]]; then + alias -s tex=$VIM + alias -s html=$VIM + alias -s md=$VIM +fi +unset $VIM + +has zathura && alias -s pdf=zathura # vim: set ft=zsh ts=2 sw=2 tw=0 noet : diff --git a/chpwd b/chpwd index e27203b..2201b3e 100644 --- a/chpwd +++ b/chpwd @@ -1,6 +1,4 @@ -HAS_GLOW="$(command -v glow)" - chpwd() { - [ -z $HAS_GLOW ] && return 0 + [ ! has glow ] && return 0 find $PWD -maxdepth 1 -iname 'readme.md' -exec glow {} \; } diff --git a/functions/has b/functions/has new file mode 100644 index 0000000..5937911 --- /dev/null +++ b/functions/has @@ -0,0 +1,8 @@ +## Has function + +has() { + Command=$1 + [[ -z $Command ]] && return 1 + + command -v $Command > /dev/null 2>&1 +} diff --git a/greet b/greet index 2fc546d..5e8dc04 100755 --- a/greet +++ b/greet @@ -1,6 +1,4 @@ -#!/bin/sh - -colours.sh +has colours.sh && colours.sh echo '╭───────────╮' echo '│ Welcome!! │' echo '╰───────────╯' @@ -15,5 +13,5 @@ if [ -d "$HOME/tmp" ]; then fi fi fi -randomVerse -colours.sh +has randomVerse && randomVerse +has colours.sh && colours.sh diff --git a/zshrc b/zshrc index 9b2f2c3..21b4426 100755 --- a/zshrc +++ b/zshrc @@ -22,6 +22,7 @@ fpath=( $ZDOTDIR/functions $fpath ) autoload CleanTmp autoload setTermTitle autoload tempPersist +autoload has ## Source Other files source ${ZDOTDIR}/aliases @@ -46,10 +47,12 @@ zle -N edit-command-line bindkey "^X^E" edit-command-line ## Enable gpg-agent support -export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket) -gpgconf --launch gpg-agent -gpg-connect-agent /bye -export GPG_TTY=$(tty) +if [[ "$USE_GPG_AGENT" == "true" ]]; then + export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket) + gpgconf --launch gpg-agent + gpg-connect-agent /bye + export GPG_TTY=$(tty) +fi ## Load external stuff @@ -83,4 +86,4 @@ source $ZDOTDIR/ZshPlug/ZshPlug.zsh [[ -n "${key[PageUp]}" ]] && bindkey "${key[PageUp]}" history-beginning-search-backward [[ -n "${key[PageDown]}" ]] && bindkey "${key[PageDown]}" history-beginning-search-forward -$ZDOTDIR/greet +source $ZDOTDIR/greet