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
|
||||
## 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 :
|
||||
|
|
|
|||
4
chpwd
4
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 {} \;
|
||||
}
|
||||
|
|
|
|||
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
|
||||
|
||||
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
|
||||
|
|
|
|||
13
zshrc
13
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
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user