Update bootstrap and more for Mac compatibility

This commit is contained in:
MoturiFranklin 2025-07-09 03:18:21 +02:00
parent a817833f66
commit c01055c142
8 changed files with 166 additions and 131 deletions

View file

@ -2,16 +2,17 @@ test -n "$PS1" || return 0
which pfetch >/dev/null 2>&1 && pfetch
alias myip='curl -4 ifconfig.me && printf "\n" && curl -6 ifconfig.me'
alias myip='curl -4 ifconfig.me && printf "\n" && curl -6 ifconfig.me && printf "\n"'
ds() {
df -B1M -x tmpfs -x devtmpfs -x squashfs -x overlay "$@" |
grep -v '\b/[^/ ]*/[^/]*/[^/]*$' | # needed for NAS to hide overly long submounts
awk -v a="\033[31m" -v b="\033[33m" -v c="\033[35m" -v n="\033[0m" 'NR==1 {printf "%-20s %6s %7s %9s %s\n",$1,$5,$3,$4,$6} NR>1 {u=$5; printf (u > 98) ? a : (u > 96) ? b : (u > 90) ? c : ""; printf "%-20s %6s %6.1fG %8.1fG %s\n",$1,$5,$3/1024,$4/1024,$6; printf n}' |
column -t
grep -v '\b/[^/ ]*/[^/]*/[^/]*$' | # needed for NAS to hide overly long submounts
awk -v a="\033[31m" -v b="\033[33m" -v c="\033[35m" -v n="\033[0m" 'NR==1 {printf "%-20s %6s %7s %9s %s\n",$1,$5,$3,$4,$6} NR>1 {u=$5; printf (u > 98) ? a : (u > 96) ? b : (u > 90) ? c : ""; printf "%-20s %6s %6.1fG %8.1fG %s\n",$1,$5,$3/1024,$4/1024,$6; printf n}' |
column -t
}
export -f ds
timeout 1s bash -c ds
which timeout 2>/dev/null &&
export -f ds &&
timeout 1s bash -c ds
test $(id -u) -eq 0 || sudo=sudo
@ -78,6 +79,7 @@ status() {
fi
}
# Find and list disks
alldisks() {
{
sudo df -h -T --exclude-type=tmpfs --exclude-type=devtmpfs --exclude-type=squashfs --exclude-type=overlay
@ -99,12 +101,12 @@ difr() { diff --color=always --unified=1 --recursive "$@" | less --RAW-CONTROL-C
# Copy recursively with rsync
alias rc='rsync --recursive --info=progress2,remove,symsafe,flist,del --human-readable --links --hard-links --times'
export LESS="--RAW-CONTROL-CHARS --ignore-case --LONG-PROMPT --jump-target=5 $(test $(less --version | head -1 | cut -f2 -d' ') -ge 590 && echo --incsearch)"
export LESS="--raw-control-chars --ignore-case --LONG-PROMPT --jump-target=5 $(test $(less --version | grep -o '\d\+' | head -1) -ge 590 && echo --incsearch)"
# ls aliases
export LS_OPTIONS='--human-readable --si --group-directories-first --dereference-command-line'
eval "$(dircolors)"
which dircolors 2>/dev/null && eval "$(dircolors)"
alias ls='ls --color=auto'
alias ll='ls $LS_OPTIONS --file-type -l'
alias la='ll --all'
@ -135,7 +137,7 @@ alias mv='mv -i'
src() { test -f "$1" && source "$1"; }
case $(readlink /proc/$$/exe) in (*bash)
case $(readlink /proc/$$/exe) in (*bash|"")
bind '"\ek":history-search-backward'
bind '"\ej":history-search-forward'
@ -143,8 +145,8 @@ shopt -oq posix || src /etc/bash_completion
# Fancy prompt
PS1="\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\W\[\033[00m\]"
PS1="$PS1 \`exitcode=\${?}; if test \$exitcode = 0; then printf '\[\033[01;32m\] :)';"
PS1="$PS1 else printf '\[\033[01;31m\]%3d' \$exitcode; fi\`\[\033[00m\]"
PS1="${PS1} \`exitcode=\${?}; if test \$exitcode = 0; then printf '\[\033[01;32m\] :)';"
PS1="${PS1} else printf '\[\033[01;31m\]%3d' \$exitcode; fi\`\[\033[00m\]"
;;
(*zsh) setopt sh_word_split;;
esac
@ -152,4 +154,4 @@ esac
src /usr/share/git/completion/git-prompt.sh && PS1="$PS1\$(__git_ps1 \" (%s)\")"
src $HOME/.config/shell/functions
PS1="$PS1 \`test \$UID = 0 && printf '#' || printf '$'\` "
PS1="${PS1} \`test \$UID = 0 && printf '#' || printf '$'\` "

View file

@ -40,6 +40,7 @@ cd() {
dir=$(fd --no-ignore --glob "$1*" "$DATA" "$MNT" --maxdepth 2 --type d --max-results 1 2>/dev/null)
test -n "$dir" && cd "$dir"
else
local LS=$(which gls 2>/dev/null || ls)
builtin cd "$@" &&
# we have to use two ls commands here, since:
# - a single ls command hangs on multi-column formats when combined with color
@ -47,9 +48,9 @@ cd() {
# column --fillrows --output-width $(expr $COLUMNS + 20)
# pr -4 -l1 -W $COLUMNS -S" "
# TODO test whether still needed with exa
command ls --sort=none --quote-name |
command $LS --sort=none --quote-name |
head -12 |
COLUMNS=$(tput cols) xargs $(which exa >/dev/null 2>&1 && echo "exa --list-dirs --icons --reverse" || echo 'ls --format=vertical --literal --classify --directory') --sort=time --color=always -- |
COLUMNS=$(tput cols) xargs $(which exa >/dev/null 2>&1 && echo "exa --list-dirs --icons --reverse" || echo "$LS --format=vertical --literal --classify --directory") --sort=time --color=always -- |
head -3
code=$? && test $code -eq 141 || return $code
fi

View file

@ -529,8 +529,8 @@ killm() {
# Files {{{1
if which exa >/dev/null
then alias l='exa --group-directories-first --icons'
if which eza >/dev/null
then alias l='eza --group-directories-first --icons'
alias ll='l --long --git --all'
else alias l='ls -F'
alias ll='l -lAh'
@ -563,7 +563,7 @@ alias rcs='rsync --recursive --info=progress2,remove,symsafe,flist,del --human-r
alias dsync='rc --delete --specials'
alias move='rc --remove-source-files'
# https://unix.stackexchange.com/questions/57305/rsync-compare-directories/177946
# You need to add a / at the end of source but NOT target: rsync -avnc $SOURCE/ $TARGET
# You need to add a / at the end of source but NOT target: rsync -avnc $SOURCE/ $TARGET
alias rdiff='rsync --info=name --recursive --checksum --delete --links --dry-run'
alias rdiffe='rdiff --existing --size-only'

View file

@ -2,9 +2,98 @@ SECTION() { printf "\n$1\n"; }
highlight() { printf "$1\n"; }
subhighlight() { printf "$1\n"; }
link() {
test -e "$2" -o -h "$2" || $($HOME/.local/bin/scripts/checkaccess -w "$2" || echo sudo) ln -sv "$@"
}
# So that bootstrapping works right after cloning with the correct env variables
source "$HOME/.zshenv"
SECTION "System"
SECTION "Dotfiles Preparation"
highlight "Remove conflicting Manjaro Sway Dotfiles"
rmexist() {
for arg
do test -e "$arg" && echo -n "$arg: " && rm -vrI "$arg"
done
}
rmexist "$XDG_CONFIG_HOME/nvim/init.lua" "$HOME/.emacs.d/"
highlight 'Resolve Home Symlinks'
touch $HOME/.local/state/wget-hsts
mkdir -p "$XDG_CONFIG_HOME/audacity"
find $HOME -maxdepth 1 -type l -exec file {} + |
grep '.local/share' | grep broken |
sed 's/.* //' | xargs -r mkdir -p
highlight 'Other Application Symlinks'
link "$XDG_CONFIG_HOME/bash/aliases.bash" "$HOME/.bashrc"
link "$HOME/.ssh/config" "$XDG_CONFIG_HOME/ssh"
link "$XDG_DATA_HOME/.cpan/CPAN/MyConfig.pm" "$XDG_CONFIG_HOME/cpan/MyConfig.pm"
link "$XDG_STATE_HOME/gradle/gradle.properties" "$XDG_CONFIG_HOME/gradle.properties"
#template() {
# local dir=$(dirname "$1")
# local file=${1/.template}
# test -d "$dir" && ! test -f "$file" &&
# cp -iv "$1" "$file"
#}
#template "$XDG_CONFIG_HOME/doom/user.template.el"
#template "$XDG_CONFIG_HOME/MuseScore/MuseScore3.template.ini"
# TODO JOSM
# TODO audacity
# TODO puddletag
SECTION 'Application Setup'
highlight "CLI Applications"
# TODO update repo users, replace slow omz
# checkout https://starship.rs/ over p10k
subhighlight "Zsh"
test -n "$ZSH" || export ZSH="${XDG_DATA_HOME:-$HOME/.local/share}/zsh/oh-my-zsh"
mkdir -p "$(dirname $ZSH)"
oldzsh="$XDG_STATE_HOME/zsh/oh-my-zsh" && test ! -d "$ZSH" -a -d "$oldzsh" && mv -vn $oldzsh $ZSH
cloneshallow() {
url=https://github.com/$2/$1.git
dir="${3:-$ZSH/plugins/$1}"
mkdir -p "$(dirname $dir)"
if test -d "$dir"
then git -C "$dir" remote set-url origin $url
else git clone --depth=1 $url "$dir"
fi
}
cloneshallow oh-my-zsh robbyrussell "$ZSH"
cloneshallow powerlevel10k romkatv "$ZSH/themes/powerlevel10k"
cloneshallow fast-syntax-highlighting zdharma-continuum
cloneshallow zsh-autosuggestions zsh-users
cloneshallow zsh-vim-mode softmoth
case "$(grep "^$USER" /etc/passwd | sed 's/.*://')" in (*zsh|'');; (*) chsh -s $(which zsh);; esac
if command -v nvim >/dev/null 2>&1; then
subhighlight "Updating NeoVim Plugins"
# TODO pynvim?
nvim '+PlugClean!' '+PlugUpgrade' '+PlugUpdate' '+qall'
fi
subhighlight "Setup kakoune plugin loader"
cloneshallow plug.kak robertmeta "$XDG_CONFIG_HOME/kak/plugins/plug.kak"
# TODO kakoune research: quit doc buffer, multi cursor, work on line
subhighlight 'Doom Emacs'
doom sync
case $(uname) in (Darwin) exit 0;; esac
# LINUX SPECIFIC
link python /usr/bin/python3
# TODO don't link these prematurely, can lead to installation conflicts
# may try /usr/local/bin
# Don't think this is needed anymore though
link fdfind /usr/bin/fd
link batcat /usr/bin/bat
SECTION "Linux System (/etc)"
highlight "Sudoers defaults"
echo 'Defaults editor=/usr/bin/nvim
@ -26,101 +115,15 @@ ExecStart=
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
highlight "Sysyadm setup"
highlight "Sysyadm Setup"
if test -d "/etc/yadm/repo.git/"
then sy l
else echo "" | sy clone
fi
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() {
local dir=$(dirname "$1")
local file=${1/.template}
test -d "$dir" && ! test -f "$file" &&
cp -iv "$1" "$file"
}
template "$XDG_CONFIG_HOME/doom/user.template.el"
template "$XDG_CONFIG_HOME/MuseScore/MuseScore3.template.ini"
# TODO JOSM
# TODO audacity
# TODO puddletag
if command -v nvim >/dev/null 2>&1; then
echo "Updating NeoVim Plugins"
# TODO pynvim?
nvim '+PlugClean!' '+PlugUpgrade' '+PlugUpdate' '+qall'
fi
link() {
test -e "$2" -o -h "$2" || $($HOME/.local/bin/scripts/checkaccess -w "$2" || echo sudo) ln -sv "$@"
}
mkdir -p "$XDG_CONFIG_HOME/audacity"
find $HOME -maxdepth 1 -type l -exec file {} + |
grep '.local/share' | grep broken |
sed 's/.* //' | xargs -r mkdir -p
link python /usr/bin/python3
# TODO don't link these prematurely, might lead to installation conflicts
link fdfind /usr/bin/fd
link batcat /usr/bin/bat
highlight "SSH Permissions"
chmod og= $HOME/.ssh -R
test -d "$HOME/.ssh/keys" && chmod a+r $HOME/.ssh/keys/*.pub
_ovpn="$XDG_DATA_HOME/openvpn"
test -d "$_ovpn" &&
sudo rm -vdf /etc/openvpn/client &&
sudo ln -vsf "$_ovpn" /etc/openvpn/client &&
sudo chmod -vR ugo-rwx,ug+rX,u+w "$_ovpn" &&
sudo chown -vR janek:openvpn "$_ovpn"
highlight "Cron"
sudo systemctl enable --now cronie
if test -d "/etc/rsyslog.d"; then
echo 'cron.* /var/log/cron.log' | sudo tee /etc/rsyslog.d/60-cron.conf
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"
test -n "$ZSH" || export ZSH="${XDG_DATA_HOME:-$HOME/.local/share}/zsh/oh-my-zsh"
mkdir -p "$(dirname $ZSH)"
oldzsh="$XDG_STATE_HOME/zsh/oh-my-zsh" && test ! -d "$ZSH" -a -d "$oldzsh" && mv -vn $oldzsh $ZSH
cloneshallow() {
url=https://github.com/$2/$1.git
dir="${3:-$ZSH/plugins/$1}"
mkdir -p "$(dirname $dir)"
if test -d "$dir"
then git -C "$dir" remote set-url origin $url
else git clone --depth=1 $url "$dir"
fi
}
cloneshallow oh-my-zsh robbyrussell "$ZSH"
cloneshallow powerlevel10k romkatv "$ZSH/themes/powerlevel10k"
cloneshallow fast-syntax-highlighting zdharma-continuum
cloneshallow zsh-autosuggestions zsh-users
cloneshallow zsh-vim-mode softmoth
case "$(grep "^$USER" /etc/passwd | sed 's/.*://')" in (*zsh);; (*) chsh -s $(which zsh);; esac
highlight "Arch"
highlight "Arch Pacman"
if test -f /etc/pacman.conf; then
# TODO adjust makepkg.conf to at least half of processor count
# TODO adjust makepkg.conf to at least half of processor count - see SPARE_CORES
subhighlight "Pacman"
sudo sed -i 's/#Parallel/Parallel/;s/#Color/Color/;s/#UseSyslog/UseSyslog/' /etc/pacman.conf
sudo sed -i "$(grep -n "\[multilib\]" /etc/pacman.conf | cut -d':' -f1),+1 s/# *//" /etc/pacman.conf
@ -137,15 +140,41 @@ if test -f /etc/pacman.conf; then
fi
fi
SECTION 'Linux Services'
highlight "Cron"
sudo systemctl enable --now cronie
if test -d "/etc/rsyslog.d"; then
echo 'cron.* /var/log/cron.log' | sudo tee /etc/rsyslog.d/60-cron.conf
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 "SSH Permissions"
chmod og= $HOME/.ssh -R
test -d "$HOME/.ssh/keys" && chmod a+r $HOME/.ssh/keys/*.pub
_ovpn="$XDG_DATA_HOME/openvpn"
test -d "$_ovpn" &&
highlight 'OpenVPN Permissions'
sudo rm -vdf /etc/openvpn/client &&
sudo ln -vsf "$_ovpn" /etc/openvpn/client &&
sudo chmod -vR ugo-rwx,ug+rX,u+w "$_ovpn" &&
sudo chown -vR janek:openvpn "$_ovpn"
test "$DISPLAY" || exit 0
SECTION "Linux App Setup"
#dasht-docsets-install haskell rails_4 >/dev/null
subhighlight "Enable MPD"
mkdir "${XDG_STATE_HOME}/mpd"
sudo systemctl enable --now mpd
mpc update
highlight "Desktop Applications"
subhighlight "Application symlinks"
link "$XDG_CONFIG_HOME/bash/aliases.bash" "$HOME/.bashrc"
link "$HOME/.ssh/config" "$XDG_CONFIG_HOME/ssh"
link "$XDG_DATA_HOME/.cpan/CPAN/MyConfig.pm" "$XDG_CONFIG_HOME/cpan/MyConfig.pm"
link "$XDG_STATE_HOME/gradle/gradle.properties" "$XDG_CONFIG_HOME/gradle.properties"
link "$XDG_DATA_HOME/applications/signal-tray.desktop" "$XDG_CONFIG_HOME/autostart/"
link "/usr/share/applications/stretchly.desktop" "$XDG_CONFIG_HOME/autostart/"
mx="$HOME/.mixxx"
@ -153,9 +182,3 @@ if ! test -d "$mx"
then mkdir "$mx" && ln -sv -t "$mx" ${XDG_DATA_HOME:-$HOME/.local/share}/mixxx/* $XDG_CONFIG_HOME/mixxx/*
fi
subhighlight "Setup kakoune plugin loader"
cloneshallow plug.kak robertmeta "$XDG_CONFIG_HOME/kak/plugins/plug.kak"
touch $HOME/.local/state/wget-hsts
dasht-docsets-install haskell rails_4 >/dev/null

View file

@ -5,12 +5,14 @@ if test "$PWD" = "$HOME" && test "$0" != "$SHELL"; then
timew | head -3
fi 2>/dev/null || return 0
ls -F --color=always
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.config/zsh/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
#if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
# source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
#fi
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
DEFAULT_USER=$USER
@ -45,7 +47,7 @@ DISABLE_UPDATE_PROMPT=true
ZSH_DISABLE_COMPFIX=true
# Fallback for fresh systems
if test -d "$ZSH"
if test -d "$ZSH"
then source $ZSH/oh-my-zsh.sh
else source $HOME/.zshenv
fi
@ -216,5 +218,3 @@ which zoxide >/dev/null &&
source_existing $HOME/.nix-profile/etc/profile.d/nix.sh
which direnv >/dev/null && eval "$(direnv hook zsh)"
l

View file

@ -260,7 +260,7 @@ if test "$ls" -o $# -le $(echo "$flags" | wc -w); then
then $elevate tree -a --dirsfirst --du -h -C -L 3 $flags -- "${ls[@]:-.}"
elif which exa 2>/dev/null >&2
then $elevate exa --icons --color=always --long --group --classify --all --all --sort=modified --reverse $flags -- "${ls[@]:-.}"
else ls -lGhFa $flags -- "${ls[@]:-.}"
else ls --color=always -lhFa $flags -- "${ls[@]:-.}"
# replaced for wider compatibility: else $elevate ls -l $(test $# -gt ${#ls[@]} && echo '-d') --color=always --human-readable --si --group-directories-first --file-type --dereference-command-line-symlink-to-dir --all $flags -- "${ls[@]:-.}"
fi
#" || $elevate ls $(test $# -gt ${#ls[@]} && echo "-d") --color=always --human-readable --si --dereference-command-line --all --sort=none $flags -- "${ls[@]:-.}"

View file

@ -86,15 +86,16 @@ mkdir -p "$XDG_STATE_HOME/zsh"
# environment
BIN="$HOME/.local/bin"
ruby_bins="$(ls -d $XDG_DATA_HOME/gem/ruby/*/bin | head -1)"
test -d "$XDG_DATA_HOME/gem/ruby" &&
ruby_bins="$(ls -d $XDG_DATA_HOME/gem/ruby/*/bin 2>/dev/null | head -1)"
export PATH="$BIN/scripts:$BIN:$RBENV_ROOT/shims:$PATH:$XDG_CONFIG_HOME/emacs/bin:$N_PREFIX:$GOPATH/bin:$ANDROID_SDK_ROOT/platform-tools:$CARGO_HOME/bin:$KREW_ROOT/bin:$ruby_bins:$HOME/.rvm/bin"
export ALTERNATE_EDITOR="$(
if which nvim >/dev/null
if command -v nvim >/dev/null
then echo nvim
else echo vi
fi)"
export EDITOR="$(
if which emacs >/dev/null
if command -v emacs >/dev/null
then echo $BIN/scripts/emacstty
else echo $ALTERNATE_EDITOR
fi

View file

@ -65,7 +65,7 @@ and configuration for ~less~ and ~fzf~.
- [[.local/bin/server][bin/server]]-scripts :: a few scripts for use on servers
* Package Setup (moving to [[https://github.com/xeruf/instalee][Instalee]])
By Size:
List installed arch packages sorted by size:
: LC_ALL=C pacman -Qi | awk '/^Name/{name=$3} /^Installed Size/{print $4$5, name}' | sort -h
Copy list of installed packages:
: pacman -Qe | cut -d\ -f1 | xclip -selection clipboard
@ -75,6 +75,14 @@ Copy list of installed packages:
Run ~yadm bootstrap~ again after starting ZSH to finish initialization.
Basic required packages for scripts: diffr fzf
Bootstrapping Steps (tbd):
- Linking of some bins (debian?)
- Desktop Applications
- Linux system config
TODO: Mac EDITOR env is overridden
** Full Personal Setup
Manjaro:
#+begin_src sh