Compare commits

..

2 commits

Author SHA1 Message Date
xeruf
eeee10a6fc bash: fix function compatibility 2023-01-18 02:02:56 +01:00
xeruf
b71d05327a config: improve zsh bootstrapping 2023-01-18 02:02:35 +01:00
5 changed files with 49 additions and 11 deletions

View file

@ -41,7 +41,7 @@ alias rm='rm -I'
alias cp='cp -i' alias cp='cp -i'
alias mv='mv -i' alias mv='mv -i'
# Bash completion # Completion and Extras
src() { test -f "$1" && source "$1"; } src() { test -f "$1" && source "$1"; }
@ -52,7 +52,6 @@ bind '"\ej":history-search-forward'
shopt -oq posix || src /etc/bash_completion shopt -oq posix || src /etc/bash_completion
# Fancy prompt # Fancy prompt
PS1="\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\W\[\033[00m\]" PS1="\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\W\[\033[00m\]"
PS1="$PS1 \`if [ \$? = 0 ]; then echo -e '\[\033[01;32m\]:)';" PS1="$PS1 \`if [ \$? = 0 ]; then echo -e '\[\033[01;32m\]:)';"
PS1="$PS1 else echo -e '\[\033[01;31m\]' \$?; fi\`\[\033[00m\]" PS1="$PS1 else echo -e '\[\033[01;31m\]' \$?; fi\`\[\033[00m\]"

View file

@ -0,0 +1,24 @@
command_not_found_handler() {
local pkgs cmd="$1"
pkgs=(${(f)"$(pkgfile -b -v -- "$cmd" 2>/dev/null)"})
if [[ -n "$pkgs" ]]; then
printf 'The application %s is not installed. It may be found in the following packages:\n' "$cmd"
printf ' %s\n' $pkgs[@]
setopt shwordsplit
pkg_array=($pkgs[@])
pkgname="${${(@s:/:)pkg_array}[2]}"
printf 'Do you want to Install package %s? (y/N) ' $pkgname
if read -q "choice? "; then
echo
echo "Executing command: pamac install $pkgname"
pamac install $pkgname
else
echo " "
fi
else
printf 'zsh: command not found: %s\n' "$cmd"
fi 1>&2
return 127
}

View file

@ -175,11 +175,11 @@ alias syslog='less +F /var/log/syslog'
alias sc='sudo systemctl' alias sc='sudo systemctl'
alias scd='sudo systemctl disable --now' alias scd='sudo systemctl disable --now'
unalias scs sce 2>/dev/null
sce() { sce() {
sudo systemctl enable --now "$@" || sudo systemctl enable --now "$@" ||
sudo systemctl status "$@" sudo systemctl status "$@"
} }
unalias scs 2>/dev/null
scs() { scs() {
( (
export SYSTEMD_COLORS=true export SYSTEMD_COLORS=true
@ -478,7 +478,7 @@ which exa >/dev/null &&
alias l='exa --icons' && alias l='exa --icons' &&
alias ll='l --long --extended --git --all' alias ll='l --long --extended --git --all'
if which fd >/dev/null if which fd >/dev/null 2>&1
then fn() { $(command -v fd || echo fdfind) --hidden --no-ignore-vcs --one-file-system "$@" | less -F; } # [F]ind [n]o ignore then fn() { $(command -v fd || echo fdfind) --hidden --no-ignore-vcs --one-file-system "$@" | less -F; } # [F]ind [n]o ignore
alias ff="noglob fn --color=always " # [F]ind [F]ile alias ff="noglob fn --color=always " # [F]ind [F]ile
compdef ff=fd compdef ff=fd

View file

@ -27,13 +27,26 @@ ExecStart=-$agetty --skip-login --login-options $USER %I" |
sudo tee /etc/systemd/system/getty@tty1.service.d/override.conf /etc/systemd/system/getty@tty2.service.d/override.conf /etc/systemd/system/getty@tty3.service.d/override.conf sudo tee /etc/systemd/system/getty@tty1.service.d/override.conf /etc/systemd/system/getty@tty2.service.d/override.conf /etc/systemd/system/getty@tty3.service.d/override.conf
highlight "Sysyadm setup" highlight "Sysyadm setup"
if test -d "/etc/yadm" if test -d "/etc/yadm/repo.git/"
then sy l then sy l
else sy clone else echo "" | sy clone
fi fi
SECTION "Software" SECTION "Software"
highlight "Cleanup Manjaro Sway Dotfiles"
rmexist() {
for arg
do test -e "$arg" && echo -n "$arg: " && rm -rI "$arg"
done
}
rmexist "$XDG_CONFIG_HOME/nvim/init.lua" "$HOME/.emacs.d/"
highlight "MPD"
mkdir "${XDG_STATE_HOME}/mpd"
sudo systemctl enable --now mpd
mpc update
template() { template() {
local dir=$(dirname "$1") local dir=$(dirname "$1")
local file=${1/.template} local file=${1/.template}
@ -76,10 +89,13 @@ test -d "$_ovpn" &&
sudo chown -vR janek:openvpn "$_ovpn" sudo chown -vR janek:openvpn "$_ovpn"
highlight "Cron" highlight "Cron"
echo 'cron.* /var/log/cron.log' | sudo tee /etc/rsyslog.d/60-cron.conf sudo systemctl enable --now cronie
hasService=$(which service 2>/dev/null) if test -d "/etc/rsyslog.d"; then
test "$hasService" && sudo service rsyslog restart || sudo systemctl restart rsyslog echo 'cron.* /var/log/cron.log' | sudo tee /etc/rsyslog.d/60-cron.conf
test "$hasService" && sudo service cron reload || sudo systemctl reload cronie hasService=$(which service 2>/dev/null)
test "$hasService" && sudo service rsyslog restart || sudo systemctl restart rsyslog
test "$hasService" && sudo service cron reload || sudo systemctl reload cronie
fi
highlight "Zsh" highlight "Zsh"
test -n "$ZSH" || export ZSH="${XDG_DATA_HOME:-$HOME/.local/share}/zsh/oh-my-zsh" test -n "$ZSH" || export ZSH="${XDG_DATA_HOME:-$HOME/.local/share}/zsh/oh-my-zsh"

View file

@ -187,7 +187,6 @@ source_existing() {
done done
} }
source_existing /usr/share/zsh/manjaro-zsh-config
source_existing $CONFIG_ZSH/.p10k.zsh # To customize prompt, run `p10k configure` or edit .p10k.zsh. source_existing $CONFIG_ZSH/.p10k.zsh # To customize prompt, run `p10k configure` or edit .p10k.zsh.
source_existing /usr/share/fzf/key-bindings.zsh /usr/share/fzf/completion.zsh source_existing /usr/share/fzf/key-bindings.zsh /usr/share/fzf/completion.zsh