diff --git a/.brew_lists/brew_list.txt.backup b/.brew_lists/brew_list.txt.backup new file mode 100644 index 0000000..e69de29 diff --git a/.brew_lists/brew_list.txt.new b/.brew_lists/brew_list.txt.new old mode 100755 new mode 100644 index 4e66de9..e69de29 --- a/.brew_lists/brew_list.txt.new +++ b/.brew_lists/brew_list.txt.new @@ -1,130 +0,0 @@ -autoconf -bat -bats-core -bfg -brotli -c-ares -ca-certificates -cairo -coreutils -curl -ddgr -docker -docker-completion -dog -eza -fd -fontconfig -freetype -fzf -gcc -gettext -gh -giflib -git -gitleaks -glib -gmp -go -gpatch -graphite2 -harfbuzz -hyperfine -ical-buddy -icu4c -isl -jpeg-turbo -jq -julia -krb5 -libevent -libgit2 -libidn2 -liblinear -libmpc -libnghttp2 -libpng -libssh2 -libtiff -libunistring -libuv -libvterm -libx11 -libxau -libxcb -libxdmcp -libxext -libxrender -little-cms2 -lpeg -lua -luajit -luarocks -luv -lz4 -lzo -m4 -marp-cli -mbedtls@2 -mpdecimal -mpfr -msgpack -ncurses -neovim -nmap -node -oniguruma -opam -openblas -openjdk -openldap -openlibm -openssl@3 -p7zip -pcre -pcre2 -pixman -pkg-config -postgresql@14 -pyenv -python@3.11 -python@3.12 -readline -ripgrep -rtmpdump -sk -skhd -sqlite -starship -stow -tmux -tree -tree-sitter -unibilium -utf8proc -uv -xorgproto -xz -yabai -zoxide -zsh -zstd -base -docker -drawio -firefox -font-symbols-only-nerd-font -google-drive -hiddenbar -insomnia -logi-options-plus -maccy -miniforge -mos -pycharm -raycast -spotify -vscodium -wezterm -zoom -zotero diff --git a/.brew_lists/cask_list.txt.backup b/.brew_lists/cask_list.txt.backup new file mode 100644 index 0000000..e69de29 diff --git a/.brew_lists/cask_list.txt.new b/.brew_lists/cask_list.txt.new old mode 100755 new mode 100644 index a37987e..e69de29 --- a/.brew_lists/cask_list.txt.new +++ b/.brew_lists/cask_list.txt.new @@ -1,19 +0,0 @@ -base -docker -drawio -firefox -font-symbols-only-nerd-font -google-drive -hiddenbar -insomnia -logi-options-plus -maccy -miniforge -mos -pycharm -raycast -spotify -vscodium -wezterm -zoom -zotero diff --git a/.gitignore b/.gitignore index 6626928..f4549ba 100755 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ *.log __pycache__* +pip* +poertry + diff --git a/poetry b/poetry new file mode 120000 index 0000000..cc45598 --- /dev/null +++ b/poetry @@ -0,0 +1 @@ +/Users/jfraeys/Library/Application Support/pypoetry/venv/bin/poetry \ No newline at end of file diff --git a/scripts/docker_check b/scripts/docker_check index d926b09..ee5858a 100755 --- a/scripts/docker_check +++ b/scripts/docker_check @@ -56,4 +56,3 @@ fi # Run the provided command "$@" - diff --git a/scripts/fzf_theme b/scripts/fzf_theme index ed083ab..22d91f6 100755 --- a/scripts/fzf_theme +++ b/scripts/fzf_theme @@ -17,18 +17,19 @@ set_fzf_theme() { fi fi - # Set fzf theme based on appearance + # Set FZF theme based on appearance if [[ $appearance == *"Dark"* || -n "$TMUX" ]]; then - FZF_DEFAULT_OPTS="--color=bg+:#272822,bg:#272822,spinner:#f92672,hl:#66d9ee,fg:#f8f8f2,header:#f92672,info:#66d9ee,pointer:#a6e22e,marker:#a6e22e,fg+:#f8f8f2,prompt:#66d9ee,hl+:#66d9ee" + # Monokai (Dark Theme) with slight adjustments + FZF_DEFAULT_OPTS="--color=bg+:#272822,bg:#272822,spinner:#ff669d,hl:#66d9ee,fg:#f8f8f2,header:#ff669d,info:#66d9ee,pointer:#a6e22e,marker:#a6e22e,fg+:#e8e8e3,prompt:#66d9ee,hl+:#66d9ee" else - FZF_DEFAULT_OPTS="--color=bg+:#fdf6e3,bg:#fdf6e3,spinner:#d33682,hl:#b58900,fg:#657b83,header:#d33682,info:#268bd2,pointer:#859900,marker:#859900,fg+:#657b83,prompt:#268bd2,hl+:#b58900" + # Solarized Light with better contrast for readability + FZF_DEFAULT_OPTS="--color=bg+:#fdf6e3,bg:#fdf6e3,spinner:#d33682,hl:#cb4b16,fg:#586e75,header:#d33682,info:#268bd2,pointer:#859900,marker:#859900,fg+:#073642,prompt:#268bd2,hl+:#cb4b16" fi - # export FZF_DEFAULT_OPTS - echo "$FZF_DEFAULT_OPTS" } -# Call the function to set FZF_DEFAULT_OPTS -set_fzf_theme "$1" - +# Call the function if executed directly +if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then + set_fzf_theme "$1" +fi diff --git a/scripts/kaggle_manager b/scripts/kaggle_manager new file mode 100755 index 0000000..9e55c57 --- /dev/null +++ b/scripts/kaggle_manager @@ -0,0 +1,171 @@ +#!/bin/bash + +# Default settings +DATASET_DIR="data/raw" # Directory to store downloaded datasets +NOTEBOOK_DIR="notebooks" # Directory to store downloaded notebooks +COMMIT_MESSAGE="Added dataset or notebook" # Default commit message +VERBOSE=0 # Default verbosity flag + +# Usage function +usage() { + echo "Usage: $0 [options]" + echo " -d, --dataset Kaggle dataset name (e.g., 'username/dataset-name') to download" + echo " -n, --notebook Kaggle notebook URL suffix (e.g., 'username/notebook-name') to download" + echo " -s, --submit Notebook file to submit to a competition" + echo " -c, --competition Competition name for notebook submission" + echo " -g, --git Flag to add and commit changes to Git after download or submission" + echo " -v, --verbose Enable verbose output" + echo " -h, --help Display this help message" + exit 1 +} + +# Parse command-line arguments +COMMIT_FLAG=0 +DATASET_NAME="" +NOTEBOOK_NAME="" +NOTEBOOK_FILE="" +COMPETITION_NAME="" + +while [[ "$#" -gt 0 ]]; do + case $1 in + -d | --dataset) + DATASET_NAME="$2" + shift + ;; + -n | --notebook) + NOTEBOOK_NAME="$2" + shift + ;; + -s | --submit) + NOTEBOOK_FILE="$2" + shift + ;; + -c | --competition) + COMPETITION_NAME="$2" + shift + ;; + -g | --git) COMMIT_FLAG=1 ;; + -v | --verbose) VERBOSE=1 ;; + -h | --help) usage ;; # Call usage function for help + *) usage ;; + esac + shift +done + +# Extract Kaggle credentials from kaggle.json +if ! KAGGLE_USERNAME=$(jq -r .username ~/.kaggle/kaggle.json) || ! KAGGLE_KEY=$(jq -r .key ~/.kaggle/kaggle.json); then + echo "Failed to retrieve Kaggle credentials from kaggle.json." + exit 1 +fi + +# Check if credentials were successfully extracted +if [[ -z "$KAGGLE_USERNAME" || -z "$KAGGLE_KEY" ]]; then + echo "Kaggle credentials are empty. Please check your kaggle.json file." + exit 1 +fi + +# Function to echo messages if verbosity is enabled +verbose_echo() { + if [[ $VERBOSE -eq 1 ]]; then + echo "$1" + fi +} + +# Download dataset +if [[ -n "$DATASET_NAME" ]]; then + # Create the dataset directory if it doesn't exist + mkdir -p "$DATASET_DIR" + + # Download the dataset using curl + verbose_echo "Downloading dataset: $DATASET_NAME to $DATASET_DIR" + if ! curl -L -o "${DATASET_DIR}/dataset.zip" \ + -u "$KAGGLE_USERNAME:$KAGGLE_KEY" \ + "https://www.kaggle.com/api/v1/datasets/download/$DATASET_NAME"; then + echo "Failed to download dataset: $DATASET_NAME" + exit 1 + fi + + # Unzip the dataset and remove the zip file + verbose_echo "Unzipping dataset..." + if ! unzip -o "${DATASET_DIR}/dataset.zip" -d "$DATASET_DIR"; then + echo "Failed to unzip dataset." + exit 1 + fi + rm "${DATASET_DIR}/dataset.zip" + + # Git add and commit if the flag is set + if [[ $COMMIT_FLAG -eq 1 ]]; then + if ! git add "$DATASET_DIR"; then + echo "Failed to add dataset to Git." + exit 1 + fi + if ! git commit -m "$COMMIT_MESSAGE: Dataset $DATASET_NAME"; then + echo "Failed to commit dataset to Git." + exit 1 + fi + verbose_echo "Committed dataset $DATASET_NAME to Git." + fi +fi + +# Download notebook +if [[ -n "$NOTEBOOK_NAME" ]]; then + # Create the notebook directory if it doesn't exist + mkdir -p "$NOTEBOOK_DIR" + + # Download the notebook using curl + verbose_echo "Downloading notebook: $NOTEBOOK_NAME to $NOTEBOOK_DIR" + if ! curl -L -o "${NOTEBOOK_DIR}/${NOTEBOOK_NAME##*/}.ipynb" \ + -u "$KAGGLE_USERNAME:$KAGGLE_KEY" \ + "https://www.kaggle.com/api/v1/kernels/source/$NOTEBOOK_NAME"; then + echo "Failed to download notebook: $NOTEBOOK_NAME" + exit 1 + fi + + # Git add and commit if the flag is set + if [[ $COMMIT_FLAG -eq 1 ]]; then + if ! git add "$NOTEBOOK_DIR"; then + echo "Failed to add notebook to Git." + exit 1 + fi + if ! git commit -m "$COMMIT_MESSAGE: Notebook $NOTEBOOK_NAME"; then + echo "Failed to commit notebook to Git." + exit 1 + fi + verbose_echo "Committed notebook $NOTEBOOK_NAME to Git." + fi +fi + +# Submit a notebook to a Kaggle competition +if [[ -n "$NOTEBOOK_FILE" && -n "$COMPETITION_NAME" ]]; then + verbose_echo "Submitting notebook: $NOTEBOOK_FILE to competition $COMPETITION_NAME" + + # Submit the notebook + if ! curl -L -X POST \ + -F "file=@${NOTEBOOK_FILE}" \ + -u "$KAGGLE_USERNAME:$KAGGLE_KEY" \ + "https://www.kaggle.com/api/v1/competitions/submissions/upload/$COMPETITION_NAME"; then + echo "Notebook submission failed." + exit 1 + else + echo "Notebook submitted successfully!" + + # Git add and commit if the flag is set + if [[ $COMMIT_FLAG -eq 1 ]]; then + if ! git add "$NOTEBOOK_FILE"; then + echo "Failed to add submitted notebook to Git." + exit 1 + fi + if ! git commit -m "$COMMIT_MESSAGE: Submitted notebook $NOTEBOOK_FILE to $COMPETITION_NAME"; then + echo "Failed to commit submitted notebook to Git." + exit 1 + fi + verbose_echo "Committed submitted notebook $NOTEBOOK_FILE to Git." + fi + fi +fi + +# If no operation was specified +if [[ -z "$DATASET_NAME" && -z "$NOTEBOOK_NAME" && -z "$NOTEBOOK_FILE" ]]; then + echo "No operation specified. Please provide a dataset, notebook, or submission to process." + usage +fi diff --git a/scripts/sessionizer b/scripts/sessionizer index c997a81..3bec013 100755 --- a/scripts/sessionizer +++ b/scripts/sessionizer @@ -69,20 +69,22 @@ handle_terminal() { local selected="$1" local selected_name + selected_name=$(basename "$selected" | tr '.' '_') + local full_path="${selected/#\~/$HOME}" + if pgrep -x tmux >/dev/null && [[ -n "$TMUX" ]]; then - selected_name=$(basename "$selected" | tr '.' '_') if ! tmux has-session -t="$selected_name" 2>/dev/null; then tmux new-session -ds "$selected_name" -c "$selected" fi tmux switch-client -t "$selected_name" elif command -v wezterm >/dev/null && wezterm --version | grep -q "wezterm"; then - local tab_id - tab_id=$(wezterm cli list | awk -v selected="$selected" 'match($0, "file://.*" selected) {print $2; exit}') - if [[ -z $tab_id ]]; then - wezterm cli spawn --cwd "$selected" - else - wezterm cli activate-tab --tab-id "$tab_id" + local workspace_exists + workspace_exists=$(wezterm cli list-workspaces | grep -w "$selected_name") + + if [[ -z $workspace_exists ]]; then + wezterm cli create-workspace --name "$selected_name" --cwd "$full_path" # Create a new workspace fi + wezterm cli switch-to-workspace --name "$selected_name" else echo "Warning: No terminal multiplexer detected (tmux or WezTerm)." >&2 exit 1 diff --git a/scripts/setup_dev_env b/scripts/setup_dev_env index 4c74a91..533ffb1 100755 --- a/scripts/setup_dev_env +++ b/scripts/setup_dev_env @@ -133,7 +133,7 @@ set_package_manager() { exit 1 fi else - echo "Unsupported operating system. Exiting." + echo "Unsupported operating system $(uname). Exiting." exit 1 fi } @@ -141,7 +141,9 @@ set_package_manager() { # Function to handle auto-updates for Homebrew handle_auto_update() { if [ "$ENABLE_AUTO_UPDATE" == true ] && [ "$PACKAGE_MANAGER" == "brew" ]; then - brew autoupdate --start --upgrade --cleanup + if command_exists brew; then + brew autoupdate --start --upgrade --cleanup + fi fi } @@ -149,15 +151,26 @@ handle_auto_update() { install_and_configure_shell() { if ! command_exists zsh; then install_dependencies "$PACKAGE_MANAGER" zsh - if [ ! -d "$HOME/.oh-my-zsh" ]; then - git clone https://github.com/ohmyzsh/ohmyzsh.git "$HOME/.oh-my-zsh" + # Replaced by zinit in .zshrc + # if [ ! -d "$HOME/.oh-my-zsh" ]; then + # git clone https://github.com/ohmyzsh/ohmyzsh.git "$HOME/.oh-my-zsh" + # fi + if [ "$SHELL" != "$(command -v zsh)" ]; then + chsh -s "$(command -v zsh)" fi - chsh -s "$(command -v zsh)" + + exec zsh -l fi } # Function to install essential tools install_essential_tools() { + if ! command_exists curl; then + install_dependencies "$PACKAGE_MANAGER" curl + fi + if ! command_exists unzip; then + install_dependencies "$PACKAGE_MANAGER" unzip + fi if ! command_exists git; then install_dependencies "$PACKAGE_MANAGER" git fd ripgrep fzf tree fi @@ -166,18 +179,80 @@ install_essential_tools() { fi } -# Function to install programming languages -install_programming_languages() { +# Function to install Go +install_go() { case $PACKAGE_MANAGER in - "brew") install_dependencies "$PACKAGE_MANAGER" go python ;; - "apt-get") install_dependencies "$PACKAGE_MANAGER" golang python3 python3-pip ;; - "yum") install_dependencies "$PACKAGE_MANAGER" golang python3 python3-pip ;; + "brew") install_dependencies "$PACKAGE_MANAGER" go ;; + "apt-get" | "yum") install_dependencies "$PACKAGE_MANAGER" golang ;; + *) + echo "Unsupported package manager: $PACKAGE_MANAGER" + exit 1 + ;; esac } +# Function to install Python and Poetry +install_python() { + # Check if "global" argument is passed + GLOBAL_INSTALL=true + if [[ "$1" == "local" ]]; then + GLOBAL_INSTALL=false + fi + + # Install pyenv if it's not already installed + if ! command -v pyenv >/dev/null 2>&1; then + echo "Installing pyenv..." + curl https://pyenv.run | bash + + # Set up pyenv in the current shell session + export PATH="$HOME/.pyenv/bin:$PATH" + eval "$(pyenv init --path)" + eval "$(pyenv init -)" + eval "$(pyenv virtualenv-init -)" + fi + + # Ensure Python 3.7+ is installed via pyenv + REQUIRED_VERSION="3.7.0" + # Function to check if the installed Python version is at least the required version + check_python_version() { + INSTALLED_VERSION=$(python -c "import sys; print('{}.{}'.format(sys.version_info.major, sys.version_info.minor))") + + if [[ $(printf '%s\n' "$REQUIRED_VERSION" "$INSTALLED_VERSION" | sort -V | head -n 1) == "$REQUIRED_VERSION" ]]; then + echo "Python version $INSTALLED_VERSION is installed and meets the requirement." + else + echo "Python version is less than $REQUIRED_VERSION. Exiting." + exit 1 + fi + } + + check_python_version + + # Set Python version globally or locally + if [[ "$GLOBAL_INSTALL" == true ]]; then + echo "Setting Python $REQUIRED_VERSION as the global version..." + pyenv global "$REQUIRED_VERSION" + else + echo "Setting Python $REQUIRED_VERSION as the local version..." + pyenv local "$REQUIRED_VERSION" + fi + + # Rehash pyenv to make the new version available + pyenv rehash + + # Install Poetry using the pyenv-installed Python + echo "Installing Poetry..." + curl -sSL https://install.python-poetry.org | python3 - +} + +# Function to install all programming languages +install_programming_languages() { + install_go + install_python global # Pass "global" as an argument to set Python globally +} + # Function to install MesloLGS Nerd Font install_meslolgs_nerd_font() { - if [ ! -f "$HOME/.local/share/fonts/MesloLGS NF Regular.tff" ]; then + if [ ! -f "$HOME/.local/share/fonts/MesloLGS NF Regular.ttf" ]; then mkdir -p ~/.local/share/fonts cd ~/.local/share/fonts || return curl -fLo "MesloLGS NF Regular.ttf" https://github.com/ryanoasis/nerd-fonts/releases/download/v2.1.0/Meslo.zip @@ -202,6 +277,8 @@ start_shell() { zsh elif command -v bash &>/dev/null; then bash + elif command -v fish &>/dev/null; then + fish else echo "Neither zsh nor bash is installed. Please install one of them manually." fi @@ -253,4 +330,3 @@ fi show_installed_dependencies start_shell -