Configure zsh
This commit is contained in:
parent
47c92124e5
commit
8dbb94f75a
11 changed files with 1901 additions and 7 deletions
|
|
@ -1,3 +1,3 @@
|
|||
# Shell-related Configuration
|
||||
|
||||
This folder contains further files that are sourced by `bash`.
|
||||
This folder contains further files that are sourced by `bash` and `zsh`.
|
||||
|
|
|
|||
|
|
@ -1,14 +1,34 @@
|
|||
# Shell aliases for bash
|
||||
# Shell aliases for bash and zsh
|
||||
|
||||
|
||||
_command_exists() {
|
||||
command -v "$1" 1>/dev/null 2>&1
|
||||
}
|
||||
|
||||
_in_zsh() {
|
||||
[ -n "$ZSH_VERSION" ]
|
||||
}
|
||||
|
||||
|
||||
# Re-run last command with sudo privileges
|
||||
alias ,,='sudo $(history -p !!)'
|
||||
if _in_zsh; then
|
||||
alias ,,='sudo $(fc -ln -1)'
|
||||
else
|
||||
alias ,,='sudo $(history -p !!)'
|
||||
fi
|
||||
|
||||
|
||||
# Convenient piping with zsh
|
||||
if _in_zsh; then
|
||||
alias -g B='| bat'
|
||||
alias -g F='| fzf'
|
||||
alias -g G='| grep'
|
||||
alias -g H='| head'
|
||||
alias -g L='| less'
|
||||
alias -g T='| tail'
|
||||
alias -g NE='2 > /dev/null'
|
||||
alias -g NUL='> /dev/null 2>&1'
|
||||
fi
|
||||
|
||||
|
||||
# (Non-)obvious synonyms
|
||||
|
|
|
|||
6
.config/shell/logout.sh
Normal file
6
.config/shell/logout.sh
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
# This file is sourced by a login shell upon logout
|
||||
|
||||
# Clear the screen to increase privacy
|
||||
if [ "$SHLVL" = 1 ]; then
|
||||
[ -x /usr/bin/clear ] && /usr/bin/clear || [ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q
|
||||
fi
|
||||
|
|
@ -5,6 +5,10 @@ _command_exists() {
|
|||
command -v "$1" 1>/dev/null 2>&1
|
||||
}
|
||||
|
||||
_in_zsh() {
|
||||
[ -n "$ZSH_VERSION" ]
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Configure the keyboard:
|
||||
|
|
@ -209,11 +213,17 @@ _update_repositories() {
|
|||
cwd=$(pwd)
|
||||
cd $REPOS
|
||||
|
||||
# Otherwise the for-loop waites for manual input
|
||||
# if it cd's into a folder with a ".env" file
|
||||
ZSH_DOTENV_FILE='.do_not_run_dotenv'
|
||||
|
||||
for dir in */; do
|
||||
cd "$REPOS/$dir" && echo "Fetching $REPOS/$dir"
|
||||
git fetch --all --prune
|
||||
done
|
||||
|
||||
ZSH_DOTENV_FILE='.env'
|
||||
|
||||
_command_exists pass && echo "Fetching $HOME/.password-store" && pass git pull
|
||||
_update_dotfiles
|
||||
|
||||
|
|
@ -232,6 +242,44 @@ _update_dotfiles() {
|
|||
}
|
||||
|
||||
|
||||
_update_zsh() {
|
||||
_in_zsh || return
|
||||
|
||||
echo 'Updating zsh'
|
||||
_update_omz_fork
|
||||
_update_zplug
|
||||
}
|
||||
|
||||
_update_omz_fork() {
|
||||
_command_exists omz || return
|
||||
|
||||
# In a nutshell, `omz update` pulls the latest origin/master
|
||||
# from the original "oh-my-zsh" repo
|
||||
omz update
|
||||
|
||||
cwd=$(pwd)
|
||||
cd $ZSH
|
||||
|
||||
git checkout --quiet forked # most likely already the case
|
||||
|
||||
# Keep our personal "oh-my-zsh" fork up-to-date
|
||||
# See: https://gitlab.webartifex.biz/alexander/oh-my-zsh
|
||||
git rebase --quiet master
|
||||
git push --quiet fork forked
|
||||
git push --quiet fork master
|
||||
|
||||
cd $cwd
|
||||
}
|
||||
|
||||
_update_zplug() {
|
||||
_command_exists zplug || return
|
||||
|
||||
zplug update
|
||||
zplug install # ensure newly added plugins in ~/.zshrc are never forgotten
|
||||
zplug load
|
||||
}
|
||||
|
||||
|
||||
update-machine() {
|
||||
sudo --validate || return
|
||||
|
||||
|
|
@ -240,6 +288,7 @@ update-machine() {
|
|||
_command_exists flatpak && sudo flatpak update -y
|
||||
_command_exists snap && sudo snap refresh && _remove_old_snaps
|
||||
_update_repositories
|
||||
_update_zsh
|
||||
|
||||
sudo --reset-timestamp
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue