Clean up zshrc from custom systemd and archlinux specific commands and outsource them into custom files

This commit is contained in:
Alexander Schäferdiek 2019-07-26 17:04:50 +02:00
parent c51abfd558
commit 8475773ea6
3 changed files with 86 additions and 76 deletions

32
etc/skel/.zsh_archlinux Normal file
View file

@ -0,0 +1,32 @@
#!/usr/bin/env zsh
alias pkgfile-update="sudo pkgfile --update"
alias pac="yay"
alias pkg-upgrade="yay && pacman-orphans && sudo paccache -rk 2 && sync"
alias pkg-upgrade-full="yay -Syyu --devel && pacman-orphans && sudo paccache -rk 2 && sync"
alias pacdiff-merge='sudo DIFFPROG=meld DIFFSEARCHPATH="/boot /etc /usr" pacdiff'
alias font-cache-update='sudo fc-cache -vf'
alias mkinitcpio-linux='sudo mkinitcpio -p linux'
pacman-orphans() {
if [[ ! -n $(pacman -Qdt) ]]; then
echo "No orphans to remove."
else
sudo pacman -Rns $(pacman -Qdtq)
fi
}
pacman-unneeded() {
ignoregrp="base base-devel"
ignorepkg=""
comm -23 <(pacman -Qqt | sort) <(echo $ignorepkg | tr ' ' '\n' | cat <(pacman -Sqg $ignoregrp) - | sort -u)
}
pacman-modified() {
pacman -Qii | awk '/^MODIFIED/ {print $2}'
}
pacman-disowned() {
sudo lostfiles
}

37
etc/skel/.zsh_systemd Normal file
View file

@ -0,0 +1,37 @@
#!/usr/bin/env zsh
alias systemctl-list-running-services="sudo systemctl --type=service"
alias systemctl-list-units='sudo systemctl list-units'
alias systemctl-list-unit-files='sudo systemctl list-unit-files'
alias systemctl-failed='sudo systemctl --failed'
alias systemctl-daemon-reload='sudo systemctl daemon-reload'
alias journalctl-error='sudo journalctl -b --priority 0..3'
alias journalctl-user='journalctl -b'
shutdown-timer() {
bash -c 'echo "System is going to shutdown in $1 minute(s)..."
sleep $1m
systemctl poweroff' -- $1
}
hibernate-timer() {
bash -c 'echo "System is going to hibernate in $1 minute(s)..."
sleep $1m
systemctl hibernate' -- $1
}
shutdown() {
systemctl poweroff
}
hibernate() {
systemctl hibernate
}
standby() {
systemctl suspend
}
restart() {
systemctl reboot
}

View file

@ -1,3 +1,7 @@
# This configuration makes use of zsh-syntax-highlighting.
# Some alias will call pre-defined applications.
# Ensure to install them if a command is not working.
#
# SETTINGS # SETTINGS
autoload -U compinit promptinit autoload -U compinit promptinit
autoload -U colors && colors autoload -U colors && colors
@ -14,10 +18,13 @@ LS_COLORS='rs=0:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;3
# HISTORY # HISTORY
HISTFILE=~/.zsh_history HISTFILE=~/.zsh_history
HISTSIZE=2000 HISTSIZE=10000
SAVEHIST=2000 SAVEHIST=10000
# ALIAS # EXPORTS
export LS_COLORS
# ALIAS & FUNCTIONS
alias ls="ls --color -F" alias ls="ls --color -F"
alias ll="ls --color -lh -a" alias ll="ls --color -lh -a"
alias ll-octal-dir='stat -c "%a %n" *' alias ll-octal-dir='stat -c "%a %n" *'
@ -32,54 +39,6 @@ alias fd='fd -H'
alias e='$EDITOR' alias e='$EDITOR'
alias edit='$EDITOR' alias edit='$EDITOR'
alias pac="yay"
alias pkg-upgrade="yay && pacman-orphans && sudo paccache -rk 2 && sync"
alias pkg-upgrade-full="yay -Syyu --devel && pacman-orphans && sudo paccache -rk 2 && sync"
alias pacdiff-merge='sudo DIFFPROG=vimdiff DIFFSEARCHPATH="/boot /etc /usr" pacdiff'
alias font-cache-update='sudo fc-cache -vf'
alias mkinitcpio-linux='sudo mkinitcpio -p linux'
alias systemctl-list-running-services="sudo systemctl --type=service"
alias systemctl-list-units='sudo systemctl list-units'
alias systemctl-list-unit-files='sudo systemctl list-unit-files'
alias systemctl-failed='sudo systemctl --failed'
alias systemctl-daemon-reload='sudo systemctl daemon-reload'
alias journalctl-error='sudo journalctl -b --priority 0..3'
alias journalctl-user='journalctl -b'
# EXPORTS
export LS_COLORS
# FUNCTIONS
# systemd
shutdown-timer() {
bash -c 'echo "System is going to shutdown in $1 minute(s)..."
sleep $1m
systemctl poweroff' -- $1
}
hibernate-timer() {
bash -c 'echo "System is going to hibernate in $1 minute(s)..."
sleep $1m
systemctl hibernate' -- $1
}
shutdown() {
systemctl poweroff
}
hibernate() {
systemctl hibernate
}
standby() {
systemctl suspend
}
restart() {
systemctl reboot
}
# misc
function chpwd() { function chpwd() {
ll ll
} }
@ -100,34 +59,16 @@ man() {
man "$@" man "$@"
} }
# pacman # SOURCE CUSTOM USER-SPECIFIC
pacman-orphans() {
if [[ ! -n $(pacman -Qdt) ]]; then
echo "No orphans to remove."
else
sudo pacman -Rns $(pacman -Qdtq)
fi
}
pacman-unneeded() {
ignoregrp="base base-devel"
ignorepkg=""
comm -23 <(pacman -Qqt | sort) <(echo $ignorepkg | tr ' ' '\n' | cat <(pacman -Sqg $ignoregrp) - | sort -u)
}
pacman-modified() {
pacman -Qii | awk '/^MODIFIED/ {print $2}'
}
pacman-disowned() {
sudo lostfiles
}
# SOURCE CUSTOM IMPORTS
if [ -f ~/.zsh_custom ]; then if [ -f ~/.zsh_custom ]; then
source ~/.zsh_custom source ~/.zsh_custom
fi fi
if [ -f ~/.zsh_systemd ]; then
source ~/.zsh_systemd
fi
if [ -f ~/.zsh_archlinux ]; then
source ~/.zsh_archlinux
fi
# KEYBINDINGS # KEYBINDINGS
typeset -A key typeset -A key