mirror of
https://github.com/Snigdha-OS/snigdhaos-roots.git
synced 2025-09-07 08:25:12 +02:00
🚀 feat(_key): add major improvements
This commit is contained in:
146
.bashrc
146
.bashrc
@@ -1,88 +1,116 @@
|
|||||||
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# ~/.bashrc
|
# ~/.bashrc
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# Function to append to PATH if not already present
|
||||||
append_path () {
|
append_path () {
|
||||||
case ":$PATH:" in
|
case ":$PATH:" in
|
||||||
*:"$1":*)
|
*:"$1":*) ;;
|
||||||
;;
|
*) PATH="${PATH:+$PATH:}$1" ;;
|
||||||
*)
|
|
||||||
PATH="${PATH:+$PATH:}$1"
|
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Add user bin directories to PATH if they exist
|
||||||
append_path "$HOME/bin"
|
append_path "$HOME/bin"
|
||||||
append_path "$HOME/.local/bin"
|
append_path "$HOME/.local/bin"
|
||||||
|
append_path "$HOME/.bin" # Append .bin only if directory exists
|
||||||
|
|
||||||
# If not running interactively, don't do anything
|
# Check if the shell is interactive, and only execute below in interactive shells
|
||||||
[[ $- != *i* ]] && return
|
[[ $- != *i* ]] && return
|
||||||
|
|
||||||
if [ -d "$HOME/.bin" ] ;
|
# Set default aliases
|
||||||
then PATH="$HOME/.bin:$PATH"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -d "$HOME/.local/bin" ] ;
|
|
||||||
then PATH="$HOME/.local/bin:$PATH"
|
|
||||||
fi
|
|
||||||
|
|
||||||
alias ls='ls -l --color=auto'
|
alias ls='ls -l --color=auto'
|
||||||
alias grep='grep --color=auto'
|
alias grep='grep --color=auto'
|
||||||
|
|
||||||
if [[ $(tty) == */dev/tty* ]]; then
|
|
||||||
PS1="\e[1;31m[\u\e[1;32mIP: $(ip -4 addr | grep -v '127.0.0.1' | grep -v 'secondary' | grep -oP '(?<=inet\s)\d+(\.\d+){3}' | sed -z 's/\n/|/g;s/|\$/\n/' | rev | cut -c 2- | rev) | \e[1;31m]\n[>]\[\e[1;31m\]\$(pwd) $ \[\e[0m\]"
|
|
||||||
else
|
|
||||||
PS1="\e[1;31m┌──[I'm \u\e[0m➜ \e[1;32mPublic IP: $(ip -4 addr | grep -v '127.0.0.1' | grep -v 'secondary' | grep -oP '(?<=inet\s)\d+(\.\d+){3}' | sed -z 's/\n/|/g;s/|\$/\n/' | rev | cut -c 2- | rev)🔒\e[1;31m]\n└──╼[\e[1;32mSNIGDHA OS\e[1;31m]\[\e[1;31m\]\$(pwd)\n$ Command: \[\e[0m\]"
|
|
||||||
fi
|
|
||||||
|
|
||||||
alias rs="sudo pacman -Rs"
|
alias rs="sudo pacman -Rs"
|
||||||
alias s="sudo pacman -S"
|
alias s="sudo pacman -S"
|
||||||
alias sy="sudo pacman -Syy"
|
alias sy="sudo pacman -Syy"
|
||||||
alias up="sudo pacman -Syyu"
|
alias syyu="sudo pacman -Syyu"
|
||||||
alias gc="git clone"
|
alias lck="sudo rm /var/lib/pacman/db.lck"
|
||||||
alias gm="git commit -m"
|
|
||||||
alias ga="git add ."
|
|
||||||
alias gp="git push"
|
|
||||||
alias ps="pip install"
|
|
||||||
alias lp="sudo pacman -U"
|
|
||||||
alias pv="python -m venv"
|
|
||||||
alias ins="sudo pacman -S"
|
|
||||||
alias unins="sudo pacman -Rs"
|
|
||||||
alias install="sudo pacman -S"
|
|
||||||
alias uninstall="sudo pacman -Rs"
|
|
||||||
alias unlock="sudo rm /var/lib/pacman/db.lck"
|
|
||||||
alias ul="sudo rm /var/lib/pacman/db.lck"
|
|
||||||
alias vm="sudo systemctl enable --now vmtoolsd.service"
|
alias vm="sudo systemctl enable --now vmtoolsd.service"
|
||||||
alias rip="expac --timefmt='%Y-%m-%d %T' '%l\t%n %v' | sort | tail -200 | nl"
|
alias rip="expac --timefmt='%Y-%m-%d %T' '%l\t%n %v' | sort | tail -200 | nl"
|
||||||
alias ys="yay -S"
|
alias ys="yay -S"
|
||||||
alias pas="paru -S"
|
alias pas="paru -S"
|
||||||
alias wget="wget -c"
|
alias wget="wget -c"
|
||||||
alias ..="cd .."
|
alias ..="cd .."
|
||||||
|
alias home="cd ~"
|
||||||
|
alias docs="cd ~/Documents"
|
||||||
|
alias dl="cd ~/Downloads"
|
||||||
|
alias music="cd ~/Music"
|
||||||
|
alias pics="cd ~/Pictures"
|
||||||
|
alias vids="cd ~/Videos"
|
||||||
|
alias desk="cd ~/Desktop"
|
||||||
|
|
||||||
|
# Enhanced file manipulation aliases
|
||||||
|
alias rm="rm -i" # Confirm before removing files
|
||||||
|
alias mv="mv -i" # Confirm before overwriting files
|
||||||
|
alias cp="cp -i" # Confirm before overwriting files
|
||||||
|
alias touch="touch -c" # Don't create a new file if it already exists
|
||||||
|
alias du="du -h --max-depth=1" # Human-readable sizes, limit depth
|
||||||
|
alias df="df -h" # Human-readable disk usage
|
||||||
|
alias find="find . -type f" # Find files only (not directories)
|
||||||
|
|
||||||
|
# Enable case-insensitive completion
|
||||||
bind "set completion-ignore-case on"
|
bind "set completion-ignore-case on"
|
||||||
|
|
||||||
ex ()
|
# Function for extracting different types of archives
|
||||||
{
|
ex () {
|
||||||
if [ -f $1 ] ; then
|
if [ -f "$1" ]; then
|
||||||
case $1 in
|
case "$1" in
|
||||||
*.tar.bz2) tar xjf $1 ;;
|
*.tar.bz2) tar xjf "$1" ;;
|
||||||
*.tar.gz) tar xzf $1 ;;
|
*.tar.gz) tar xzf "$1" ;;
|
||||||
*.bz2) bunzip2 $1 ;;
|
*.bz2) bunzip2 "$1" ;;
|
||||||
*.rar) unrar x $1 ;;
|
*.rar) unrar x "$1" ;;
|
||||||
*.gz) gunzip $1 ;;
|
*.gz) gunzip "$1" ;;
|
||||||
*.tar) tar xf $1 ;;
|
*.tar) tar xf "$1" ;;
|
||||||
*.tbz2) tar xjf $1 ;;
|
*.tbz2) tar xjf "$1" ;;
|
||||||
*.tgz) tar xzf $1 ;;
|
*.tgz) tar xzf "$1" ;;
|
||||||
*.zip) unzip $1 ;;
|
*.zip) unzip "$1" ;;
|
||||||
*.Z) uncompress $1;;
|
*.Z) uncompress "$1" ;;
|
||||||
*.7z) 7z x $1 ;;
|
*.7z) 7z x "$1" ;;
|
||||||
*.deb) ar x $1 ;;
|
*.deb) ar x "$1" ;;
|
||||||
*.tar.xz) tar xf $1 ;;
|
*.tar.xz) tar xf "$1" ;;
|
||||||
*.tar.zst) tar xf $1 ;;
|
*.tar.zst) tar xf "$1" ;;
|
||||||
*) echo "'$1' cannot be extracted via ex()" ;;
|
*) echo "'$1' cannot be extracted via ex()" ;;
|
||||||
esac
|
esac
|
||||||
else
|
else
|
||||||
echo "'$1' is not a valid file"
|
echo "'$1' is not a valid file"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ $1 != no-repeat-flag && -z $NO_REPETITION ]]; then
|
# Custom PS1 prompt with IP address and conditional formatting based on terminal type
|
||||||
neofetch
|
get_ip_address() {
|
||||||
|
# Extract non-local IP address
|
||||||
|
ip -4 addr show | grep -v '127.0.0.1' | grep -oP '(?<=inet\s)\d+(\.\d+){3}' | head -n 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if in a terminal session
|
||||||
|
if [[ $(tty) == */dev/tty* ]]; then
|
||||||
|
PS1="\e[1;31m[\u\e[1;32mIP: $(get_ip_address) | \e[1;31m]\n[>]\[\e[1;31m\]\$(pwd) $ \[\e[0m\]"
|
||||||
|
else
|
||||||
|
PS1="\e[1;31m┌──[I'm \u\e[0m➜ \e[1;32mPublic IP: $(get_ip_address)🔒\e[1;31m]\n└──╼[\e[1;32mSNIGDHA OS\e[1;31m]\[\e[1;31m\]\$(pwd)\n$ Command: \[\e[0m\]"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Display system information via neofetch if the flag is not set
|
||||||
|
if [[ $1 != "no-repeat-flag" && -z $NO_REPETITION ]]; then
|
||||||
|
neofetch
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Additional useful aliases
|
||||||
|
alias cls="clear" # Clear the terminal screen
|
||||||
|
alias h="history" # Show command history
|
||||||
|
alias upg="sudo pacman -Syu" # Update system
|
||||||
|
alias restart="sudo reboot" # Restart system
|
||||||
|
alias shutdown="sudo shutdown -h now" # Shutdown system
|
||||||
|
alias halt="sudo shutdown -h now" # Shutdown system (alternative)
|
||||||
|
alias lock="i3lock" # Lock screen
|
||||||
|
alias logs="journalctl -xe" # Show system logs
|
||||||
|
alias t="tmux" # Start tmux session
|
||||||
|
alias top="htop" # Use htop instead of top
|
||||||
|
alias cpu="lscpu" # Display CPU info
|
||||||
|
alias mem="free -h" # Display memory info
|
||||||
|
alias battery="upower -i $(upower -e | grep 'BAT') | grep 'state\|percentage'" # Battery status
|
||||||
|
|
||||||
|
# Navigate the system more efficiently
|
||||||
|
alias src="cd ~/src" # Navigate to source code directory
|
||||||
|
alias code="code ." # Open VSCode in current directory
|
||||||
|
97
push.sh
97
push.sh
@@ -1,27 +1,86 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Author : Eshan Roy <eshan@snigdhaos.org>
|
# Author : ESHAN ROY
|
||||||
# Author URI : https://eshanized.github.io/
|
# Author URI : https://eshanized.github.io
|
||||||
|
|
||||||
# NOTE: REPO = Your Repository Name On the Host
|
# Define the conventional commit types with new emojis
|
||||||
# NOTE: ORG = Your ORGANIZATION NAME or USERNAME
|
TYPES=("🚀 feat" "🐛 fix" "📝 docs" "✨ style" "🛠 refactor" "⚡️ perf" "🔬 test" "🔧 build" "🤖 ci" "🧹 chore" "⏪ revert")
|
||||||
# NOTE: HOST = GitHub, Gitlab, Bitbucket etc.
|
|
||||||
|
|
||||||
# Repo Config
|
# Function to display an error and exit and
|
||||||
REPO=snigdhaos-roots
|
error_exit() {
|
||||||
# Host Config
|
echo -e "\033[1;31m[ERROR]\033[0m $1"
|
||||||
HOST=https://github.com
|
exit 1
|
||||||
# Destination Config
|
}
|
||||||
ORG=Snigdha-OS
|
|
||||||
|
|
||||||
# Set the repository URL and branch
|
# Ensure the script is run in a Git repository
|
||||||
REPO_URL="${HOST}/${ORG}/${REPO}.git"
|
git rev-parse --is-inside-work-tree > /dev/null 2>&1 || error_exit "This is not a Git repository."
|
||||||
BRANCH="master" # or "main" depending on your repository's default branch
|
|
||||||
|
|
||||||
# Commit message
|
# Get the current branch name
|
||||||
MESSAGE="@eshanized: push via script"
|
branch=$(git rev-parse --abbrev-ref HEAD)
|
||||||
|
|
||||||
# Add all files, commit, and push changes
|
# Pull the latest changes from the remote repository
|
||||||
|
echo "Pulling latest changes from remote branch '$branch'..."
|
||||||
|
git pull origin "$branch" || error_exit "Failed to pull changes from the remote repository. Please resolve any conflicts manually."
|
||||||
|
|
||||||
|
# Prompt the user to select a commit type
|
||||||
|
echo "Select a commit type:"
|
||||||
|
select type in "${TYPES[@]}"; do
|
||||||
|
if [[ -n "$type" ]]; then
|
||||||
|
break
|
||||||
|
else
|
||||||
|
echo "Invalid selection. Please try again."
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Extract the commit type and emoji from the selection
|
||||||
|
type_emoji=${type}
|
||||||
|
type=${type_emoji#* }
|
||||||
|
emoji=${type_emoji% *}
|
||||||
|
|
||||||
|
# Prompt the user to enter a scope (optional)
|
||||||
|
read -p "Enter a scope (optional): " scope
|
||||||
|
scope_part=""
|
||||||
|
if [ -n "$scope" ]; then
|
||||||
|
scope_part="($scope)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Prompt the user to enter a short description
|
||||||
|
read -p "Enter a short description: " desc
|
||||||
|
if [ -z "$desc" ]; then
|
||||||
|
error_exit "A short description is required!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Prompt the user to enter a longer description (optional)
|
||||||
|
read -p "Enter a longer description (optional): " long_desc
|
||||||
|
|
||||||
|
# Create the commit message
|
||||||
|
commit_msg="$emoji $type$scope_part: $desc"
|
||||||
|
|
||||||
|
# If a longer description was provided, add it to the commit message
|
||||||
|
if [ -n "$long_desc" ]; then
|
||||||
|
commit_msg+="
|
||||||
|
|
||||||
|
$long_desc"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Print the commit message to the console
|
||||||
|
echo -e "\nCommit message:"
|
||||||
|
echo -e "\033[1;36m$commit_msg\033[0m"
|
||||||
|
|
||||||
|
# Stage all changes
|
||||||
git add .
|
git add .
|
||||||
git commit -m "$MESSAGE"
|
|
||||||
git push origin $BRANCH
|
# Commit the changes with the conventional commit message
|
||||||
|
if git commit -m "$commit_msg"; then
|
||||||
|
echo -e "\033[1;32mCommit successful!\033[0m"
|
||||||
|
else
|
||||||
|
error_exit "Commit failed."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Push the changes to the remote repository
|
||||||
|
echo "Pushing changes to remote branch '$branch'..."
|
||||||
|
if git push origin "$branch"; then
|
||||||
|
echo -e "\033[1;32mChanges pushed to remote branch '$branch'.\033[0m"
|
||||||
|
else
|
||||||
|
error_exit "Push failed. Please check your connection or branch permissions."
|
||||||
|
fi
|
Reference in New Issue
Block a user