Skip to content

Commit

Permalink
Merge pull request #20 from omar-besbes/lint
Browse files Browse the repository at this point in the history
style: lint project
  • Loading branch information
omar-besbes authored Feb 8, 2025
2 parents 373fff8 + 145556d commit a4257ee
Show file tree
Hide file tree
Showing 32 changed files with 437 additions and 448 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
.env
/src/neovim/nvim
/test
!/test/test.sh
!/test/test.sh
5 changes: 5 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[*.sh]
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true
9 changes: 5 additions & 4 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
[ ! -v DOTFILES_ROOT_DIR ] && declare -r DOTFILES_ROOT_DIR="$HOME/.dotfiles"

mkdir -p "$DOTFILES_ROOT_DIR"
mkdir -p "$DOTFILES_BASH_COMPLETIONS_DIR"
cd "$DOTFILES_ROOT_DIR" || exit 1

[ ! -v CURRENT_BRANCH ] &&
Expand All @@ -35,6 +34,8 @@ source "$DOTFILES_ROOT_DIR/scripts/setup_topics.sh" &>/dev/null ||
source "$DOTFILES_ROOT_DIR/scripts/sync_files.sh" &>/dev/null ||
source <(curl -fsSL "$DOTFILES_GITHUB_RAW_CONTENT_ORIGIN/scripts/sync_files.sh")

mkdir -p "$DOTFILES_BASH_COMPLETIONS_DIR"

# ----------------------------------------------------------------------
# | Global Dependencies |
# ----------------------------------------------------------------------
Expand All @@ -47,6 +48,9 @@ install_dependencies() {
# install curl
execute "sudo apt-get install -y curl" "Installing curl ..."

# isntall necessary compression and extraction tools
execute "sudo apt-get install -y bzip2 gzip zip xz-utils tar" "Installing extraction/compression tools ..."

# install rustup & cargo
if ! cmd_exists rustup; then
execute "curl --proto '=https' --tlsv1.2 -fsSL https://sh.rustup.rs | sh -s -- --no-modify-path -y" "Installing rustup ..."
Expand All @@ -71,9 +75,6 @@ install_dependencies() {
# install xclip
execute "sudo apt-get install -y xclip" "Installing xclip ..."

# isntall necessary compression and extraction tools
execute "sudo apt-get install -y bzip2 gzip zip xz-utils tar" "Installing extraction/compression tools ..."

# install gcc, g++ & some other tools
execute "sudo apt-get install -y ca-certificates fontconfig build-essential software-properties-common" "Installing essential tools ..."

Expand Down
3 changes: 1 addition & 2 deletions scripts/load_topics.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[ ! -v TOPIC_INIT_FILE ] && declare -r TOPIC_INIT_FILE="init.sh"

load_topics() {

local -r SOURCE_DIR=$1
local -a TOPICS_TO_LOAD=$(find $SOURCE_DIR -mindepth 2 -maxdepth 2 -type f -name $TOPIC_INIT_FILE -exec dirname {} \; 2>/dev/null)

Expand All @@ -14,4 +14,3 @@ load_topics() {
done

}

5 changes: 2 additions & 3 deletions scripts/setup_topics.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/bash

[ ! -v TOPIC_SETUP_FILE ] && declare -r TOPIC_SETUP_FILE="setup.sh"
[ ! -v TOPIC_SETUP_FILE ] && declare -r TOPIC_SETUP_FILE="setup.sh"

setup_topics() {

local -r SOURCE_DIR=$1
local -a TOPICS_TO_SETUP=$(find $SOURCE_DIR -mindepth 2 -maxdepth 2 -type f -name $TOPIC_SETUP_FILE -exec dirname {} \; 2>/dev/null)

Expand All @@ -14,4 +14,3 @@ setup_topics() {
done

}

17 changes: 8 additions & 9 deletions scripts/sync_files.sh
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
#!/bin/bash

[ ! -v DOTFILES_ROOT_DIR ] && declare -r DOTFILES_ROOT_DIR="$HOME/.dotfiles"
[ ! -v DOTFILES_GITHUB_ORIGIN ] && declare -r DOTFILES_GITHUB_ORIGIN="https://github.com/omar-besbes/.dotfiles"
[ ! -v DOTFILES_ROOT_DIR ] && declare -r DOTFILES_ROOT_DIR="$HOME/.dotfiles"
[ ! -v DOTFILES_GITHUB_ORIGIN ] && declare -r DOTFILES_GITHUB_ORIGIN="https://github.com/omar-besbes/.dotfiles"

print_info() {
echo -e "\e[34m$1\e[0m"
}

sync_dotfiles() {

if ! git rev-parse --is-inside-work-tree &> /dev/null; then
if ! git rev-parse --is-inside-work-tree &>/dev/null; then
# ======================================= #
# case: FIRST TIME INSTALL #
# ======================================= #

print_info " [ℹ️] No DOTFILES where detected, beginning a remote install ..."

# if directory contains anything, move it to /backups/.dotfiles except /backups, of course
[ ! -z $(ls -A "$DOTFILES_ROOT_DIR") ] && \
mkdir "$DOTFILES_ROOT_DIR/backups/.dotfiles" && \
[ ! -z $(ls -A "$DOTFILES_ROOT_DIR") ] &&
mkdir "$DOTFILES_ROOT_DIR/backups/.dotfiles" &&
find "$DOTFILES_ROOT_DIR" -maxdepth 1 -mindepth 1 -not -name "backups"
find "$DOTFILES_ROOT_DIR" -maxdepth 1 -mindepth 1 -not -name "backups" -exec mv -t "$ROOT_DIR/backups/.dotfiles" {} +
find "$DOTFILES_ROOT_DIR" -maxdepth 1 -mindepth 1 -not -name "backups" -exec mv -t "$ROOT_DIR/backups/.dotfiles" {} +

# clone repository recursively
git clone -b main "$DOTFILES_GITHUB_ORIGIN" "$DOTFILES_ROOT_DIR"
git clone -b main "$DOTFILES_GITHUB_ORIGIN" "$DOTFILES_ROOT_DIR"
git submodule sync --recursive
git submodule update --init --recursive
else
Expand All @@ -41,4 +41,3 @@ sync_dotfiles() {
fi

}

4 changes: 2 additions & 2 deletions src/browser/brave/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ install_dependencies() {
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/brave-browser-archive-keyring.gpg] \
https://brave-browser-apt-release.s3.brave.com/ stable main" | \
sudo tee /etc/apt/sources.list.d/brave-browser-release.list > /dev/null
https://brave-browser-apt-release.s3.brave.com/ stable main" |
sudo tee /etc/apt/sources.list.d/brave-browser-release.list >/dev/null
sudo apt-get update

# Install package
Expand Down
2 changes: 1 addition & 1 deletion src/browser/chromium/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ source "$DOTFILES_SCRIPTS_DIR/symlink_files.sh"
install_dependencies() {

sudo apt-get update
sudo apt-get install -y chromium
sudo apt-get install -y chromium

}

Expand Down
6 changes: 3 additions & 3 deletions src/browser/opera/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ install_dependencies() {

# Add Opera's official GPG key:
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://deb.opera.com/archive.key | \
sudo curl -fsSL https://deb.opera.com/archive.key |
gpg --dearmor -o /usr/share/keyrings/opera-browser.gpg

# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/opera-browser.gpg] \
http://deb.opera.com/opera/ stable non-free" | \
sudo tee /etc/apt/sources.list.d/opera-archive.list > /dev/null
http://deb.opera.com/opera/ stable non-free" |
sudo tee /etc/apt/sources.list.d/opera-archive.list >/dev/null
sudo apt-get update

# Install package
Expand Down
1 change: 0 additions & 1 deletion src/browser/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,3 @@ choose_browser() {
main() {
choose_browser
}

11 changes: 5 additions & 6 deletions src/docker/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ source "$ROOT_DIR/scripts/utils.sh"
# ----------------------------------------------------------------------

install_dependencies() {
cmd_exists docker && return;

cmd_exists docker && return

local -r codename="$(. /etc/os-release && echo "$VERSION_CODENAME")"
local -r id="$(. /etc/os-release && echo "$ID")"
Expand All @@ -31,8 +31,8 @@ install_dependencies() {
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] \
https://download.docker.com/linux/$id $codename stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
https://download.docker.com/linux/$id $codename stable" |
sudo tee /etc/apt/sources.list.d/docker.list
sudo apt-get update

# Install packages
Expand All @@ -54,10 +54,9 @@ install_dependencies() {
# ----------------------------------------------------------------------

main() {

ask_for_sudo

install_dependencies

}

5 changes: 2 additions & 3 deletions src/fonts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ source "$ROOT_DIR/scripts/utils.sh"
# ----------------------------------------------------------------------

install_nerd_fonts() {

local -r FONT_DIR="$HOME/.local/share/fonts/truetype"
local -r NERD_FONTS_GITHUB_ORIGIN="https://github.com/ryanoasis/nerd-fonts"
local -a FONTS_TO_INSTALL=("Hack" "JetBrainsMono" "RobotoMono" "NerdFontsSymbolsOnly")

# Ensure the font directory exists
mkdir -p "$FONT_DIR"

Expand Down Expand Up @@ -51,4 +51,3 @@ install_nerd_fonts() {
main() {
install_nerd_fonts
}

1 change: 1 addition & 0 deletions src/git/gitconfig
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
cm = commit -m
unstage = restore --staged
uncommit = reset --soft HEAD~
unstash = stash pop
root = rev-parse --show-toplevel
last = log -1
amend = commit --amend
Expand Down
5 changes: 2 additions & 3 deletions src/git/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ source "$DOTFILES_SCRIPTS_DIR/symlink_files.sh"

create_symlinks() {

local -a FILES_TO_SYMLINK=("$TOPIC_DIR/gitconfig")
local -a FILES_TO_SYMLINK=("$TOPIC_DIR/gitconfig")
local -r TARGET_PATHS=("$HOME/.gitconfig")
symlink_files FILES_TO_SYMLINK[@] TARGET_PATHS[@]
symlink_files FILES_TO_SYMLINK[@] TARGET_PATHS[@]

}

Expand All @@ -35,4 +35,3 @@ main() {
create_symlinks

}

4 changes: 2 additions & 2 deletions src/helm/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ install_dependencies() {

# Add kubectl's official GPG key:
curl https://baltocdn.com/helm/signing.asc |
sudo gpg --dearmor -o /usr/share/keyrings/helm.gpg
sudo gpg --dearmor -o /etc/apt/keyrings/helm.gpg
sudo apt-get install apt-transport-https --yes

# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/helm.gpg] \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/helm.gpg] \
https://baltocdn.com/helm/stable/debian/ all main" |
sudo tee /etc/apt/sources.list.d/helm-stable-debian.list
sudo apt-get update
Expand Down
12 changes: 6 additions & 6 deletions src/kubectl/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,20 @@ source "$ROOT_DIR/scripts/utils.sh"
# ----------------------------------------------------------------------

install_dependencies() {
cmd_exists kubectl && return;

cmd_exists kubectl && return

# Add kubectl's official GPG key:
sudo apt-get update
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.29/deb/Release.key | \
local -r VERSION=$(curl -L -s https://dl.k8s.io/release/stable.txt | cat | cut -f 1-2 -d '.')
curl -fsSL "https://pkgs.k8s.io/core:/stable:/$VERSION/deb/Release.key" |
sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg

# Add the repository to Apt sources:
echo \
"deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] \
https://pkgs.k8s.io/core:/stable:/v1.29/deb/ /" | \
https://pkgs.k8s.io/core:/stable:/$VERSION/deb/ /" |
sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update

Expand All @@ -42,10 +43,9 @@ install_dependencies() {
# ----------------------------------------------------------------------

main() {

ask_for_sudo

install_dependencies

}

2 changes: 0 additions & 2 deletions src/shell/bash_completion/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,3 @@ declare -r COMPLETION_FILES=$(find $DOTFILES_BASH_COMPLETIONS_DIR -type f)
for i in ${COMPLETION_FILES[@]}; do
source $i
done


7 changes: 3 additions & 4 deletions src/shell/bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
*i*) ;;
*) return ;;
esac

DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
Expand All @@ -27,8 +27,7 @@ TOPIC_DIR="$DOTFILES_SOURCE_DIR/$TOPIC_NAME"
# ----------------------------------------------------------------------

main() {
load_topics $TOPIC_DIR
load_topics $TOPIC_DIR
}

main

18 changes: 9 additions & 9 deletions src/shell/core/default.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color|*-256color) color_prompt=yes;;
xterm-color | *-256color) color_prompt=yes ;;
esac

# uncomment for a colored prompt, if the terminal has the capability; turned
Expand All @@ -14,14 +14,14 @@ esac
#force_color_prompt=yes

if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi

# colored GCC warnings and errors
Expand Down
17 changes: 8 additions & 9 deletions src/shell/core/env.sh
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
#!/bin/bash

# Set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
if [ -d "$HOME/bin" ]; then
PATH="$HOME/bin:$PATH"
fi
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
if [ -d "$HOME/.local/bin" ]; then
PATH="$HOME/.local/bin:$PATH"
fi

# nvm
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion

# cargo
source "$HOME/.cargo/env"

# pnpm
export PNPM_HOME="/home/omar/.local/share/pnpm"
case ":$PATH:" in
*":$PNPM_HOME:"*) ;;
*) export PATH="$PNPM_HOME:$PATH" ;;
*":$PNPM_HOME:"*) ;;
*) export PATH="$PNPM_HOME:$PATH" ;;
esac

# deno
source "$HOME/.deno/env"

1 change: 0 additions & 1 deletion src/shell/core/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ for theme in $(vivid themes); do
tree .dotfiles
echo
done

Loading

0 comments on commit a4257ee

Please sign in to comment.