break scripts from zshrc to separate scripts

This commit is contained in:
doman 2023-11-14 19:04:03 +01:00
parent 9ae14fd7ab
commit c22ec9638c
5 changed files with 66 additions and 61 deletions

View file

@ -0,0 +1,10 @@
# Base16 Shell
if ! {[ -n "$TMUX" ] || [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]}; then
BASE16_SHELL="$HOME/.config/base16-shell/"
source "$BASE16_SHELL/profile_helper.sh" 2>/dev/null
BASE16_SHELL_SET_BACKGROUND=false
fi
if ! {[ -n "$TMUX" ] || [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]}; then
base16_ocean
fi

21
.config/scriptrc/ex.sh Normal file
View file

@ -0,0 +1,21 @@
ex ()
{
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via ex()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}

19
.config/scriptrc/mac.sh Normal file
View file

@ -0,0 +1,19 @@
setupmac() {
defaults write com.apple.dock expose-animation-duration -float 0.1
defaults write -g InitialKeyRepeat -int 12
defaults write -g KeyRepeat -int 1
defaults write com.apple.Dock autohide-delay -float 0; killall Dock
defaults write -g com.apple.mouse.scaling -integer -1
}
check_ssh_add() {
if [[ "$(ssh-add -l)" == "The agent has no identities." ]] ; then
ssh-add ~/.ssh/id_rsa
setupmac
fi
}
if [[ "$(uname)" == "Darwin" ]]; then
check_ssh_add
fi

View file

@ -0,0 +1,6 @@
# run neofetch or tmux if available
if [ ! -z "$(which tmux 2>/dev/null)" ]; then
if [ ! -n "$TMUX" ] || [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
exec tmux
fi
fi

71
.zshrc
View file

@ -179,20 +179,6 @@ bindkey '^R' history-incremental-search-backward
bindkey '\eOH' beginning-of-line bindkey '\eOH' beginning-of-line
bindkey '\eOF' end-of-line bindkey '\eOF' end-of-line
# Load aliases and shortcuts if existent.
if [ -d "$HOME/.config/aliasrc" ]; then
for ALIASFILE in $HOME/.config/aliasrc/*; do
source $ALIASFILE
done
fi
# Load scripts
if [ -d "$HOME/.config/scriptrc" ]; then
for SCRIPTFILE in $HOME/.config/scriptrc/*; do
source $SCRIPTFILE
done
fi
# IMPORTA # IMPORTA
if [ ! -z "$(which nvim 2>/dev/null)" ]; then if [ ! -z "$(which nvim 2>/dev/null)" ]; then
export EDITOR=nvim export EDITOR=nvim
@ -200,29 +186,6 @@ else
export EDITOR=vim export EDITOR=vim
fi fi
# must have function!
ex ()
{
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via ex()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
# load plugins # load plugins
source ~/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh 2>/dev/null source ~/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh 2>/dev/null
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh 2>/dev/null source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh 2>/dev/null
@ -243,30 +206,16 @@ export LDFLAGS="-L/opt/homebrew/opt/mysql-client/lib"
export CPPFLAGS="-I/opt/homebrew/opt/mysql-client/include" export CPPFLAGS="-I/opt/homebrew/opt/mysql-client/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/mysql-client/lib/pkgconfig" export PKG_CONFIG_PATH="/opt/homebrew/opt/mysql-client/lib/pkgconfig"
# Base16 Shell # Load aliases and shortcuts if existent.
if ! {[ -n "$TMUX" ] || [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]}; then if [ -d "$HOME/.config/aliasrc" ]; then
BASE16_SHELL="$HOME/.config/base16-shell/" for ALIASFILE in $HOME/.config/aliasrc/*; do
source "$BASE16_SHELL/profile_helper.sh" 2>/dev/null source $ALIASFILE
BASE16_SHELL_SET_BACKGROUND=false done
fi fi
if ! {[ -n "$TMUX" ] || [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]}; then # Load scripts
base16_ocean if [ -d "$HOME/.config/scriptrc" ]; then
fi for SCRIPTFILE in $HOME/.config/scriptrc/*; do
source $SCRIPTFILE
cached_neofetch () done
{
# [ ! -z $HOME/.neofetch_cache ] && [ ! -z "$(which neofetch 2>/dev/null)" ] && neofetch > $HOME/.neofetch_cache
# cat $HOME/.neofetch_cache 2>/dev/null
}
# run neofetch or tmux if available
if [ ! -z "$(which tmux 2>/dev/null)" ]; then
if [ -n "$TMUX" ] || [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
cached_neofetch
else
exec tmux
fi
else
cached_neofetch
fi fi