Added new PS1 prompt and universal package manager, p.

This commit is contained in:
2024-01-05 19:06:17 +00:00
parent f8f6d57f69
commit 538f7053f8
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,5 +1,13 @@
#! /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
function ask() {
read -p "$1 (Y/n): " resp
@@ -14,64 +22,75 @@ function ask() {
# Upgrade
echo "Updating packages..."
kgx -e "sudo pacman -Syu && sudo pacman -S git"
read -p "Press enter to continue."
p
p i git
# Mirrors
if ask "Choose best mirrors (LONG TIME)?"; then
kgx -e "sudo pacman -S reflector && sudo reflector --sort rate -p https --save /etc/pacman.d/mirrorlist --verbose"
if [ $dist == 2 ]; then
if ask "Choose best mirrors (LONG TIME)?"; then
sudo pacman -S reflector
sudo reflector --sort rate -p https --save /etc/pacman.d/mirrorlist --verbose
read -p "Press enter to continue."
fi
fi
# Install paru
paru=$(pacman -Q paru)
if [[ -n "$paru" ]]; then
if [ $dist == 2 ]; then
paru=$(pacman -Q paru)
if [[ -n "$paru" ]]; then
echo -e "\e[32m[I] Paru is already installed.\e[0m"
else
kgx -e "sudo pacman -S --needed base-devel && \
git clone https://aur.archlinux.org/paru.git && \
cd paru && \
makepkg -si && \
cd .. && \
rm -rf paru"
else
sudo pacman -S --needed base-devel
git clone https://aur.archlinux.org/paru.git
cd paru
makepkg -si
cd ..
rm -rf paru
fi
read -p "Press enter to continue."
fi
read -p "Press enter to continue."
# Enable bluetooth support
if ask "Enable bluetooth?"; then
kgx -e "sudo pacman -S bluez bluez-utils && \
sudo systemctl start bluetooth.service; \
sudo systemctl enable bluetooth.service"
if [ $dist == 2 ]; then
if ask "Enable bluetooth?"; then
sudo pacman -S bluez bluez-utils
sudo systemctl start bluetooth.service
sudo systemctl enable bluetooth.service
fi
fi
# Enable printer support
if ask "Enable CUPS (printer)?"; then
kgx -e "sudo pacman -S cups && \
sudo systemctl start cups; \
sudo systemctl start cups.service; \
sudo systemctl enable cups; \
sudo systemctl enable cups.service"
if [ $dist == 2 ]; then
if ask "Enable CUPS (printer)?"; then
sudo pacman -S cups
sudo systemctl start cups
sudo systemctl start cups.service
sudo systemctl enable cups
sudo systemctl enable cups.service
fi
fi
# Install Tela Icons
echo "Installing Tela Icon Theme..."
kgx -e "git clone https://github.com/vinceliuice/Tela-circle-icon-theme.git && \
cd Tela-circle-icon-theme && \
./install.sh ; \
cd .. && \
rm -rf Tela-circle-icon-theme; \
gsettings set org.gnome.desktop.interface icon-theme 'Tela-circle'"
read -p "Press enter to continue."
git clone https://github.com/vinceliuice/Tela-circle-icon-theme.git
cd Tela-circle-icon-theme
./install.sh
cd ..
rm -rf Tela-circle-icon-theme
gsettings set org.gnome.desktop.interface icon-theme 'Tela-circle'
# Install 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'"
read -p "Press enter to continue."
p i bibata-cursor-theme
gsettings set org.gnome.desktop.interface cursor-theme 'Bibata-Modern-Classic'
# Install Nerd Font
echo "Installing JetBrains font..."
kgx -e "sudo pacman -S ttf-jetbrains-mono-nerd"
read -p "Press enter to continue."
if [ $dist == 2 ]; then
p i ttf-jetbrains-mono-nerd
else
p i fonts-jetbrains-mono
fi
# Enable minimize button
echo "Enabling minimize button..."
@@ -79,8 +98,12 @@ gsettings set org.gnome.desktop.wm.preferences button-layout ":minimize,close"
# Enable flatpak support
if ask "Enable flatpak?"; then
kgx -e "sudo pacman -S flatpak && \
flatpak install flatseal; \
sudo flatpak override --filesystem=$HOME/.themes; \
sudo flatpak override --filesystem=$HOME/.icons"
p i flatpak
flatpak install flatseal
sudo flatpak override --filesystem=$HOME/.themes
sudo flatpak override --filesystem=$HOME/.icons
fi
# Copy configs
echo "Copying configs..."
cp -rf homeConfigs/.* ~

View File

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