Added new PS1 prompt and universal package manager, p.

This commit is contained in:
2024-01-05 19:06:17 +00:00
parent 307e0809ea
commit 0fdac6c705
5 changed files with 168 additions and 51 deletions

12
homeConfigs/.bashrc Normal file
View File

@@ -0,0 +1,12 @@
#
# ~/.bashrc
#
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
source ~/dotfiles/scripts/p.sh
alias ls='ls --color=auto'
alias grep='grep --color=auto'
PS1='\n[\[\e[37m\]\u\[\e[0m\]@\[\e[37;2m\]\h\[\e[0m\]] \[\e[1m\]\w \[\e[0;2m\]J:\[\e[0m\]\j\n\$ '

View File

@@ -1,77 +1,96 @@
#! /bin/bash #! /bin/bash
source ./scripts/p.sh # Universal package manager
dist=$(d)
if [ $dist == 0 ]; then
echo "ERROR - Distro not supported."
return 1
fi
# Ask Y/n # Ask Y/n
function ask() { function ask() {
read -p "$1 (Y/n): " resp read -p "$1 (Y/n): " resp
if [ -z "$resp" ]; then if [ -z "$resp" ]; then
response_lc="y" # empty is Yes response_lc="y" # empty is Yes
else else
response_lc=$(echo "$resp" | tr '[:upper:]' '[:lower:]') # case insensitive response_lc=$(echo "$resp" | tr '[:upper:]' '[:lower:]') # case insensitive
fi fi
[ "$response_lc" = "y" ] [ "$response_lc" = "y" ]
} }
# Upgrade # Upgrade
echo "Updating packages..." echo "Updating packages..."
kgx -e "sudo pacman -Syu && sudo pacman -S git" p
read -p "Press enter to continue." p i git
# Mirrors # Mirrors
if ask "Choose best mirrors (LONG TIME)?"; then if [ $dist == 2 ]; then
kgx -e "sudo pacman -S reflector && sudo reflector --sort rate -p https --save /etc/pacman.d/mirrorlist --verbose" if ask "Choose best mirrors (LONG TIME)?"; then
read -p "Press enter to continue." sudo pacman -S reflector
sudo reflector --sort rate -p https --save /etc/pacman.d/mirrorlist --verbose
read -p "Press enter to continue."
fi
fi fi
# Install paru # Install paru
paru=$(pacman -Q paru) if [ $dist == 2 ]; then
if [[ -n "$paru" ]]; then paru=$(pacman -Q paru)
echo -e "\e[32m[I] Paru is already installed.\e[0m" if [[ -n "$paru" ]]; then
else echo -e "\e[32m[I] Paru is already installed.\e[0m"
kgx -e "sudo pacman -S --needed base-devel && \ else
git clone https://aur.archlinux.org/paru.git && \ sudo pacman -S --needed base-devel
cd paru && \ git clone https://aur.archlinux.org/paru.git
makepkg -si && \ cd paru
cd .. && \ makepkg -si
rm -rf paru" cd ..
rm -rf paru
fi
read -p "Press enter to continue."
fi fi
read -p "Press enter to continue."
# Enable bluetooth support # Enable bluetooth support
if ask "Enable bluetooth?"; then if [ $dist == 2 ]; then
kgx -e "sudo pacman -S bluez bluez-utils && \ if ask "Enable bluetooth?"; then
sudo systemctl start bluetooth.service; \ sudo pacman -S bluez bluez-utils
sudo systemctl enable bluetooth.service" sudo systemctl start bluetooth.service
sudo systemctl enable bluetooth.service
fi
fi fi
# Enable printer support # Enable printer support
if ask "Enable CUPS (printer)?"; then if [ $dist == 2 ]; then
kgx -e "sudo pacman -S cups && \ if ask "Enable CUPS (printer)?"; then
sudo systemctl start cups; \ sudo pacman -S cups
sudo systemctl start cups.service; \ sudo systemctl start cups
sudo systemctl enable cups; \ sudo systemctl start cups.service
sudo systemctl enable cups.service" sudo systemctl enable cups
sudo systemctl enable cups.service
fi
fi fi
# Install Tela Icons # Install Tela Icons
echo "Installing Tela Icon Theme..." echo "Installing Tela Icon Theme..."
kgx -e "git clone https://github.com/vinceliuice/Tela-circle-icon-theme.git && \ git clone https://github.com/vinceliuice/Tela-circle-icon-theme.git
cd Tela-circle-icon-theme && \ cd Tela-circle-icon-theme
./install.sh ; \ ./install.sh
cd .. && \ cd ..
rm -rf Tela-circle-icon-theme; \ rm -rf Tela-circle-icon-theme
gsettings set org.gnome.desktop.interface icon-theme 'Tela-circle'" gsettings set org.gnome.desktop.interface icon-theme 'Tela-circle'
read -p "Press enter to continue."
# Install Cursor theme # Install Cursor theme
echo "Installing Cursor Theme..." echo "Installing Cursor Theme..."
kgx -e "paru -S bibata-cursor-theme-bin && gsettings set org.gnome.desktop.interface cursor-theme 'Bibata-Modern-Classic'" p i bibata-cursor-theme
read -p "Press enter to continue." gsettings set org.gnome.desktop.interface cursor-theme 'Bibata-Modern-Classic'
# Install Nerd Font # Install Nerd Font
echo "Installing JetBrains font..." echo "Installing JetBrains font..."
kgx -e "sudo pacman -S ttf-jetbrains-mono-nerd" if [ $dist == 2 ]; then
read -p "Press enter to continue." p i ttf-jetbrains-mono-nerd
else
p i fonts-jetbrains-mono
fi
# Enable minimize button # Enable minimize button
echo "Enabling minimize button..." echo "Enabling minimize button..."
@@ -79,8 +98,12 @@ gsettings set org.gnome.desktop.wm.preferences button-layout ":minimize,close"
# Enable flatpak support # Enable flatpak support
if ask "Enable flatpak?"; then if ask "Enable flatpak?"; then
kgx -e "sudo pacman -S flatpak && \ p i flatpak
flatpak install flatseal; \ flatpak install flatseal
sudo flatpak override --filesystem=$HOME/.themes; \ sudo flatpak override --filesystem=$HOME/.themes
sudo flatpak override --filesystem=$HOME/.icons" sudo flatpak override --filesystem=$HOME/.icons
fi fi
# Copy configs
echo "Copying configs..."
cp -rf homeConfigs/.* ~

View File

@@ -1,10 +1,12 @@
#! /bin/bash #! /bin/bash
ollama=$(pacman -Q ollama) source ./p.sh
if [[ -n "$ollama" ]]; then if [[ $(p c ollama) == 0 ]]; then
kgx -e "ollama serve" kgx -e "ollama serve"
sleep 1 sleep 1
kgx -e "ollama run codellama" kgx -e "ollama run codellama"
else else
kgx -e "sudo paru -S ollama; echo 'Run the script again...'" d i ollama
echo
echo 'Run the script again...'
fi fi

80
scripts/p.sh Executable file
View File

@@ -0,0 +1,80 @@
#! /bin/bash
# Cross-distro package manager
# p -> update os
# p i package -> install package
# p r package -> remove package
# p c package -> check if package is installed (0 -> installed; 1 -> not installed; 2 -> ERROR)
# d -> returns 1 -> Debian; 2 -> Arch; 0 -> Error
d() {
if [ "$(grep -Ei 'debian|buntu|mint' /etc/*release)" ]; then
echo 1
elif [ "$(grep -Ei 'arch|manjaro|artix' /etc/*release)" ]; then
echo 2
else
echo 0
fi
}
p() {
# Detect distro type
if [ "$(grep -Ei 'debian|buntu|mint' /etc/*release)" ]; then
distro="DEB"
update="sudo apt update; sudo apt upgrade; sudo apt autoremove"
install="sudo apt install"
remove="sudo apt remove"
elif [ "$(grep -Ei 'arch|manjaro|artix' /etc/*release)" ]; then
distro="ARCH"
update="sudo pacman -Syu"
install="sudo pacman -S"
remove="sudo pacman -R"
else
echo "DISTRO NOT SUPPORTED"
return 1
fi
# If no parameter
if [ -z $1 ]; then
$update
return 0
fi
# If first parameter is i (install)
if [ $1 == "i" ]; then
$install $2
if [ $? == 0 ]; then
return 0
else
return 2
fi
fi
# If first parameter is r (remove)
if [ $1 == "r" ]; then
$remove $2
if [ $? == 0 ]; then
return 0
else
return 2
fi
fi
if [ $1 == "c" ]; then
if [ "$distro" == "DEB" ]; then
if dpkg-query -W -f='${Status}' $2 2>/dev/null | grep -q "install ok installed"; then
echo 0
else
echo 1
fi
elif [ "$distro" == "ARCH" ]; then
if pacman -Qs $2 >/dev/null; then
echo 0
else
echo 1
fi
else
echo 2
fi
fi
}