fix: add some compatibility options
this commit introduces the `has` function. Now I can ensure that any command I want to alias or call is available first. This should allow the config to automatically slot in even where systems aren't configured in the way I would expect
This commit is contained in:
parent
a029d2f348
commit
5d1484881e
37
aliases
37
aliases
|
|
@ -34,21 +34,23 @@
|
||||||
|
|
||||||
## Use Exa instead of ls
|
## Use Exa instead of ls
|
||||||
## REQUIRES NERD FONT
|
## REQUIRES NERD FONT
|
||||||
alias ls='exa --icons --group-directories-first'
|
has exa && alias ls='exa --icons --group-directories-first'
|
||||||
|
|
||||||
## Shorten xdg-open
|
## Shorten xdg-open
|
||||||
alias xopen='xdg-open'
|
has xdg-open && alias xopen='xdg-open'
|
||||||
|
|
||||||
## cls Clear Screen run ls
|
## cls Clear Screen run ls
|
||||||
alias cls='clear; ls'
|
alias cls='clear; ls'
|
||||||
|
|
||||||
## Shorten scriptedit
|
## Shorten scriptedit
|
||||||
## REQUIRES scriptedit (Script)
|
## REQUIRES scriptedit (Script)
|
||||||
alias se='scriptedit'
|
has scriptedit && alias se='scriptedit'
|
||||||
|
|
||||||
## YouTube downloader
|
## YouTube downloader
|
||||||
alias yt='youtube-dl'
|
if has youtube-dl ; then
|
||||||
alias yta='youtube-dl --ignore-config --add-metadata --ignore-errors --extract-audio --format "bestaudio/best"'
|
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'
|
alias cp='cp --interactive --verbose'
|
||||||
|
|
@ -62,10 +64,10 @@ alias grep='grep --color=auto'
|
||||||
alias ip='ip --color=auto'
|
alias ip='ip --color=auto'
|
||||||
|
|
||||||
## Open Vimwiki
|
## Open Vimwiki
|
||||||
alias vw='nvim -c VimwikiIndex'
|
has nvim && alias vw='nvim -c VimwikiIndex'
|
||||||
|
|
||||||
## Change Wineprefix quick and EZ
|
## Change Wineprefix quick and EZ
|
||||||
alias ws='source wineselect'
|
has wineselect && alias ws='source wineselect'
|
||||||
|
|
||||||
## zero a terminal session
|
## zero a terminal session
|
||||||
alias zero='dirs -c && clear'
|
alias zero='dirs -c && clear'
|
||||||
|
|
@ -74,11 +76,24 @@ alias zero='dirs -c && clear'
|
||||||
# FileType Associations #
|
# FileType Associations #
|
||||||
# extension=program #
|
# 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
|
if [[ -n $VIM ]]; then
|
||||||
alias -s html=nvim
|
alias -s tex=$VIM
|
||||||
alias -s pdf=zathura
|
alias -s html=$VIM
|
||||||
alias -s md=nvim
|
alias -s md=$VIM
|
||||||
|
fi
|
||||||
|
unset $VIM
|
||||||
|
|
||||||
|
has zathura && alias -s pdf=zathura
|
||||||
|
|
||||||
|
|
||||||
# vim: set ft=zsh ts=2 sw=2 tw=0 noet :
|
# vim: set ft=zsh ts=2 sw=2 tw=0 noet :
|
||||||
|
|
|
||||||
4
chpwd
4
chpwd
|
|
@ -1,6 +1,4 @@
|
||||||
HAS_GLOW="$(command -v glow)"
|
|
||||||
|
|
||||||
chpwd() {
|
chpwd() {
|
||||||
[ -z $HAS_GLOW ] && return 0
|
[ ! has glow ] && return 0
|
||||||
find $PWD -maxdepth 1 -iname 'readme.md' -exec glow {} \;
|
find $PWD -maxdepth 1 -iname 'readme.md' -exec glow {} \;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
8
functions/has
Normal file
8
functions/has
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
## Has function
|
||||||
|
|
||||||
|
has() {
|
||||||
|
Command=$1
|
||||||
|
[[ -z $Command ]] && return 1
|
||||||
|
|
||||||
|
command -v $Command > /dev/null 2>&1
|
||||||
|
}
|
||||||
8
greet
8
greet
|
|
@ -1,6 +1,4 @@
|
||||||
#!/bin/sh
|
has colours.sh && colours.sh
|
||||||
|
|
||||||
colours.sh
|
|
||||||
echo '╭───────────╮'
|
echo '╭───────────╮'
|
||||||
echo '│ Welcome!! │'
|
echo '│ Welcome!! │'
|
||||||
echo '╰───────────╯'
|
echo '╰───────────╯'
|
||||||
|
|
@ -15,5 +13,5 @@ if [ -d "$HOME/tmp" ]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
randomVerse
|
has randomVerse && randomVerse
|
||||||
colours.sh
|
has colours.sh && colours.sh
|
||||||
|
|
|
||||||
13
zshrc
13
zshrc
|
|
@ -22,6 +22,7 @@ fpath=( $ZDOTDIR/functions $fpath )
|
||||||
autoload CleanTmp
|
autoload CleanTmp
|
||||||
autoload setTermTitle
|
autoload setTermTitle
|
||||||
autoload tempPersist
|
autoload tempPersist
|
||||||
|
autoload has
|
||||||
|
|
||||||
## Source Other files
|
## Source Other files
|
||||||
source ${ZDOTDIR}/aliases
|
source ${ZDOTDIR}/aliases
|
||||||
|
|
@ -46,10 +47,12 @@ zle -N edit-command-line
|
||||||
bindkey "^X^E" edit-command-line
|
bindkey "^X^E" edit-command-line
|
||||||
|
|
||||||
## Enable gpg-agent support
|
## Enable gpg-agent support
|
||||||
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
|
if [[ "$USE_GPG_AGENT" == "true" ]]; then
|
||||||
gpgconf --launch gpg-agent
|
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
|
||||||
gpg-connect-agent /bye
|
gpgconf --launch gpg-agent
|
||||||
export GPG_TTY=$(tty)
|
gpg-connect-agent /bye
|
||||||
|
export GPG_TTY=$(tty)
|
||||||
|
fi
|
||||||
|
|
||||||
## Load external stuff
|
## Load external stuff
|
||||||
|
|
||||||
|
|
@ -83,4 +86,4 @@ source $ZDOTDIR/ZshPlug/ZshPlug.zsh
|
||||||
[[ -n "${key[PageUp]}" ]] && bindkey "${key[PageUp]}" history-beginning-search-backward
|
[[ -n "${key[PageUp]}" ]] && bindkey "${key[PageUp]}" history-beginning-search-backward
|
||||||
[[ -n "${key[PageDown]}" ]] && bindkey "${key[PageDown]}" history-beginning-search-forward
|
[[ -n "${key[PageDown]}" ]] && bindkey "${key[PageDown]}" history-beginning-search-forward
|
||||||
|
|
||||||
$ZDOTDIR/greet
|
source $ZDOTDIR/greet
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user