Last active
January 13, 2024 17:16
-
-
Save Muizzyranking/d0c18bcee6cc145a166ae6c3ee4098aa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Function to check if a command exists | |
| command_exists() { | |
| command -v "$1" >/dev/null 2>&1 | |
| } | |
| # Function to install dependencies on Fedora | |
| install_dependencies_fedora() { | |
| for package in "$@"; do | |
| if ! command_exists "$package"; then | |
| sudo dnf install -y "$package" | |
| else | |
| echo "$package is already installed." | |
| fi | |
| done | |
| } | |
| # Update the system only once | |
| if [ ! -f "/tmp/system_updated" ]; then | |
| echo "Updating system..." | |
| sudo dnf update -y | |
| echo "System updated successfully." | |
| fi | |
| # Install Git and Curl | |
| echo "Installing Git and Curl..." | |
| install_dependencies_fedora git curl | |
| # Check and install Oh My Zsh | |
| if [ -n "$ZSH_VERSION" ]; then | |
| echo "Oh My Zsh is already installed." | |
| else | |
| echo "Installing Oh My Zsh..." | |
| sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" | |
| echo "Oh My Zsh installed and set as default shell." | |
| fi | |
| # Install Powerlevel10k | |
| echo "Installing Powerlevel10k..." | |
| git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k | |
| echo "Powerlevel10k installed successfully." | |
| # Clone and set up your dot-files repository | |
| XDG_HOME_CONFIG_DIR="$HOME/.config" | |
| DOTFILES_REPO="https://github.com/Muizzyranking/dot-files" | |
| echo "Setting up your dot-files from $DOTFILES_REPO..." | |
| # Check if the XDG_HOME_CONFIG directory exists, create it if not | |
| if [ ! -d "$XDG_HOME_CONFIG_DIR" ]; then | |
| mkdir -p "$XDG_HOME_CONFIG_DIR" | |
| fi | |
| # Change to the XDG_HOME_CONFIG directory | |
| cd "$XDG_HOME_CONFIG_DIR" || exit | |
| # Initialize a Git repository | |
| if [ ! -d "$XDG_HOME_CONFIG_DIR/.git" ]; then | |
| git init | |
| fi | |
| # Add your GitHub repository as the remote origin | |
| git remote add origin "$DOTFILES_REPO" | |
| # Fetch the latest changes from the repository | |
| git fetch origin | |
| # Reset the working directory to the latest commit | |
| git reset --hard origin/master | |
| echo "Dot-files cloned and set up successfully in $XDG_HOME_CONFIG_DIR." | |
| # Create a symlink for Zsh configuration file | |
| ZSH_CONFIG_FILE="$XDG_HOME_CONFIG_DIR/shell/zsh" | |
| ZSHRC_FILE="$HOME/.zshrc" | |
| if [ -f "$ZSH_CONFIG_FILE" ]; then | |
| # Remove existing .zshrc if it exists | |
| [ -f "$ZSHRC_FILE" ] && rm "$ZSHRC_FILE" | |
| # Create a symlink for Zsh configuration file | |
| ln -s "$ZSH_CONFIG_FILE" "$ZSHRC_FILE" | |
| echo "Symlink created for Zsh configuration file: $ZSH_CONFIG_FILE → $ZSHRC_FILE" | |
| else | |
| echo "Zsh configuration file not found: $ZSH_CONFIG_FILE" | |
| fi | |
| # Install tmux and Tmux Plugin Manager (tpm) | |
| echo "Installing tmux and Tmux Plugin Manager (tpm)..." | |
| install_dependencies_fedora tmux | |
| git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm | |
| echo "tmux and tpm installed successfully." | |
| # Install Tmux plugins using tpm | |
| tmux new-session -d -s temp_session | |
| ~/.tmux/plugins/tpm/bin/install_plugins | |
| tmux kill-session -t temp_session | |
| echo "Tmux plugins installed successfully." | |
| # Install additional tools on Fedora | |
| echo "Installing additional tools on Fedora: Neovim, Python 3, Node.js, ripgrep, fd-find..." | |
| install_dependencies_fedora neovim python3 nodejs ripgrep fd-find | |
| # Install LazyGit | |
| echo "Installing LazyGit..." | |
| sudo dnf copr enable atim/lazygit -y | |
| sudo dnf install lazygit | |
| # Cleanup: Remove the system update marker file | |
| chsh -s "$(which zsh)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment