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