initialize rewritten

This commit is contained in:
pvincent
2026-08-21 00:54:19 +04:00
parent 261444bf31
commit 1be1134f9b
2 changed files with 28 additions and 28 deletions
+22 -26
View File
@@ -13,7 +13,7 @@ readonly AZERTY_ZONES=(
'Pacific/Tahiti' 'Pacific/Tahiti'
) )
readonly REQUIRED_PKGS=(file jq vim git) readonly REQUIRED_PKGS=(file jq vim git)
readonly BACKUP='ORIGINAL' readonly BACKUP_SUFFIX='.ORIGINAL'
# FUNCTIONS # FUNCTIONS
@@ -67,25 +67,22 @@ function fix_users_bashrc {
} }
function link_etc { function link_etc {
local filename="$1" subfolder="${2:-}" local source="$MIAOU_BASH_DIR/etc/$1"
local link_name="$filename" local target="/etc/${2:-$1}"
[[ -v LINK_NAME ]] && link_name="$LINK_NAME"
local source="$MIAOU_BASH_DIR/etc" if [[ -L "$target" ]]; then
local destination="/etc" if [[ "$(readlink "$target")" != "$source" ]]; then
[[ -n "$subfolder" ]] && source+="/${subfolder}" && destination+="/${subfolder}" sudo ln -sf "$source" "$target"
if [[ -L "$destination/$link_name" ]]; then echo "link $target updated"
if [[ "$(readlink "$destination/$link_name")" != "$source/$filename" ]]; then
ln -sf "$source/$filename" "$destination/$link_name"
echo "link $source/$link_name updated"
fi fi
else else
if [[ -f "$destination/$link_name" ]]; then if [[ -f "$target" ]]; then
mv "$destination/$link_name" "$destination/$link_name.$BACKUP" sudo mv "$target" "$target$BACKUP_SUFFIX"
echo "$destination/$link_name.$BACKUP saved!" echo "$target$BACKUP_SUFFIX saved!"
fi fi
ln -s "$source/$filename" "$destination/$link_name" sudo mkdir -p "$(dirname "$target")"
echo "link $source/$link_name created" sudo ln -s "$source" "$target"
echo "link $target created"
fi fi
} }
@@ -120,17 +117,17 @@ function is_debian_like {
function link_config_files { function link_config_files {
is_arch_like && arch_vimrc && arch_profile is_arch_like && arch_vimrc && arch_profile
link_etc vimrc.core vim link_etc vim/vimrc.core
link_etc vimrc.miaou vim link_etc vim/vimrc.miaou
link_etc vimrc.rookie vim link_etc vim/vimrc.rookie
if in_azerty_zone 2>/dev/null; then if in_azerty_zone 2>/dev/null; then
link_etc vimrc.azerty vim link_etc vim/vimrc.azerty
LINK_NAME=vimrc.local link_etc vimrc.local.azerty vim link_etc vim/vimrc.local.azerty vim/vimrc.local
else else
link_etc vimrc.local vim link_etc vim/vimrc.local
fi fi
link_etc 20-miaou-bash.sh profile.d link_etc profile.d/20-miaou-bash.sh
link_etc bash.bashrc link_etc bash.bashrc
link_etc inputrc # last command required to detect successful installation link_etc inputrc # last command required to detect successful installation
} }
@@ -171,8 +168,7 @@ function build_associative_user_homes {
function ghostty_global_config { function ghostty_global_config {
! command -v ghostty >/dev/null && return # ghostty not yet installed! ! command -v ghostty >/dev/null && return # ghostty not yet installed!
sudo mkdir -p /etc/ghostty link_etc ghostty/config
link_etc config ghostty
if [[ ! -f /etc/skell/.config/ghostty/config ]]; then if [[ ! -f /etc/skell/.config/ghostty/config ]]; then
# ghostty config skeleton for new users # ghostty config skeleton for new users
@@ -206,8 +202,8 @@ function ghostty_global_config {
# MAIN # MAIN
source "$MIAOU_BASH_DIR/lib/functions.bash" source "$MIAOU_BASH_DIR/lib/functions.bash"
assert_root
assert_root
DISTRO_LIKE=$(fetch_distro_like) DISTRO_LIKE=$(fetch_distro_like)
install_required_packages install_required_packages
fix_users_bashrc fix_users_bashrc
+6 -2
View File
@@ -26,8 +26,12 @@ function uninstall {
sudo rm -f /usr/bin/miaou-bash sudo rm -f /usr/bin/miaou-bash
sudo rm -rf /opt/miaou-bash sudo rm -rf /opt/miaou-bash
echo 'MIAOU-BASH fully uninstalled, previous settings have been restored from original' cat <<EOF
echo -e "To reset your shell, please run:\n\texec bash -l" MIAOU-BASH succesfully uninstalled.
Previous settings have been restored from original.
To reset this session, you can run:
exec bash -l
EOF
} }
# Main # Main