diff --git a/bin/actions/export.sh b/bin/actions/export.sh index b751da5..64750e4 100755 --- a/bin/actions/export.sh +++ b/bin/actions/export.sh @@ -5,4 +5,7 @@ source ~/dotfiles/bin/helpers/functions.sh printfe "%s\n" "cyan" "Exporting Gnome Terminal preferences" dconf dump /org/gnome/terminal/ > ~/dotfiles/config/gterminal.preferences +printfe "%s\n" "cyan" "Exporting VSCode extensions" +code --list-extensions | jq -R -s -c 'split("\n")[:-1]' > ~/dotfiles/vscode/extensions.json + printfe "%s\n" "green" "Finished, don't forget to commit and push" \ No newline at end of file diff --git a/bin/actions/status.sh b/bin/actions/status.sh index f679c58..c4bd0ef 100755 --- a/bin/actions/status.sh +++ b/bin/actions/status.sh @@ -1,4 +1,61 @@ #!/usr/bin/env zsh source ~/dotfiles/bin/helpers/functions.sh +source ~/dotfiles/bin/helpers/packages.sh +source ~/dotfiles/bin/helpers/vscode-extensions.sh +# Check if parameter --verbose was passed +if [ "$2" = "--verbose" ]; then + verbose=true +else + verbose=false +fi + +# count entries in packages +count=$(echo $packages | wc -w) +installed=0 + +for package in $packages; do + pkg_status=$(dpkg -s $package 2> /dev/null | grep "Status" | cut -d " " -f 4) + + if [ "$pkg_status" = "installed" ]; then + installed=$((installed + 1)) + else + if [ "$verbose" = true ]; then + printfe "%s\n" "red" "$package is not installed" + fi + fi +done + +printfe "%s\n" "cyan" "APT $installed/$count packages installed" + + +load_vscode_extensions +count_installed_extensions=0 + +# Loop through each extension and check if it's installed +for extension in "${extensionList[@]}"; do + result=$(code --list-extensions | grep -E "^${extension}$") + if [ -z "$result" ]; then + if [ "$verbose" = true ]; then + printfe "%s" "yellow" "Extension $extension is not installed\n" + fi + else + count_installed_extensions=$((count_installed_extensions + 1)) + fi +done + +if [ "$verbose" = true ]; then + printfe "%s\n" "yellow" "Expected extensions:" + for ext in "${extensionList[@]}"; do + printfe "%s\n" "blue" "$ext" + done + + printfe "%s\n" "yellow" "Installed extensions:" + while IFS= read -r installed_ext; do + printfe "%s\n" "blue" "$installed_ext" + done < <(code --list-extensions) +fi + +total_extensions=${#extensionList[@]} +printfe "%s\n" "cyan" "VSCode $count_installed_extensions/$total_extensions extensions installed" diff --git a/bin/actions/update.sh b/bin/actions/update.sh index 0eaef8e..103364c 100755 --- a/bin/actions/update.sh +++ b/bin/actions/update.sh @@ -19,6 +19,10 @@ printfe "%s\n" "cyan" "Ensuring packages are installed..." source ~/dotfiles/bin/helpers/packages.sh ensure_packages_installed +printfe "%s\n" "cyan" "Ensuring VSCode extensions are installed..." +source ~/dotfiles/bin/helpers/vscode-extensions.sh +ensure_vscode_extensions_installed + printfe "%s\n" "cyan" "Importing Gnome Terminal preferences..." cat ~/dotfiles/config/gterminal.preferences | dconf load /org/gnome/terminal/legacy/profiles:/ diff --git a/bin/helpers/packages.sh b/bin/helpers/packages.sh index c9cfd6e..a59099e 100644 --- a/bin/helpers/packages.sh +++ b/bin/helpers/packages.sh @@ -55,7 +55,10 @@ ensure_packages_installed() { fi for package in $packages; do - if ! command -v $package &> /dev/null; then + pkg_status=$(dpkg -s $package 2> /dev/null | grep "Status" | cut -d " " -f 4) + + # If pkg_status is `installed` then we don't need to install the package, otherwise if it's empty then the package is not installed + if [ -z $pkg_status ]; then printfe "%s" "yellow" "Installing $package..." echo -en "\r" diff --git a/bin/helpers/vscode-extensions.sh b/bin/helpers/vscode-extensions.sh new file mode 100644 index 0000000..f613b75 --- /dev/null +++ b/bin/helpers/vscode-extensions.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env zsh + +source ~/dotfiles/bin/helpers/functions.sh + +load_vscode_extensions() { + # Clear the array before populating it + arr=() + while IFS= read -r line; do + arr+=("$line") + done < <(jq -r '.[]' ~/dotfiles/vscode/extensions.json) + # Export the array + export extensionList=("${arr[@]}") +} + +ensure_vscode_extensions_installed() { + # Load extensions list from jq in ~/dotfiles/vscode/extensions.json + load_vscode_extensions + + for extension in "${extensionList[@]}"; do + result=$(code --list-extensions | grep -E "^${extension}$") + if [ -z "$result" ]; then + printfe "%s" "yellow" "Installing $extension..." + code --install-extension $extension + + if [ $? -ne 0 ]; then + printfe "%s\n" "red" "Failed to install $extension" + exit 1 + fi + printfe "%s\n" "green" "Installed $extension" + else + printfe "%s\n" "green" "$extension is already installed" + fi + done +} diff --git a/bin/resources/help.txt b/bin/resources/help.txt index 814eaeb..6681eda 100644 --- a/bin/resources/help.txt +++ b/bin/resources/help.txt @@ -4,5 +4,6 @@ Usage: dotf [options] [optional parameters] update: Pull latest changes, and update symlinks and configurations. export: Export dconf, gsettings, and other configurations. + status: Show the status of the dotfiles repository. help: Shows this help message \ No newline at end of file diff --git a/config/gterminal.preferences b/config/gterminal.preferences index 9efde25..22f2ab4 100644 --- a/config/gterminal.preferences +++ b/config/gterminal.preferences @@ -25,3 +25,31 @@ font='MesloLGS Nerd Font 14' foreground-color='rgb(208,207,204)' use-system-font=false use-theme-colors=false + +[legacy/profiles:/legacy/profiles:/legacy/keybindings] +reset-and-clear='k' + +[legacy/profiles:/legacy/profiles:/legacy/profiles:/:b1dcc9dd-5262-4d8d-a863-c897e6d979b9] +background-color='rgb(23,20,33)' +cursor-blink-mode='on' +cursor-shape='underline' +default-size-columns=120 +default-size-rows=30 +font='MesloLGS Nerd Font 14' +foreground-color='rgb(208,207,204)' +use-system-font=false +use-theme-colors=false + +[legacy/profiles:/legacy/profiles:/legacy/profiles:/legacy/keybindings] +reset-and-clear='k' + +[legacy/profiles:/legacy/profiles:/legacy/profiles:/legacy/profiles:/:b1dcc9dd-5262-4d8d-a863-c897e6d979b9] +background-color='rgb(23,20,33)' +cursor-blink-mode='on' +cursor-shape='underline' +default-size-columns=120 +default-size-rows=30 +font='MesloLGS Nerd Font 14' +foreground-color='rgb(208,207,204)' +use-system-font=false +use-theme-colors=false diff --git a/vscode/extensions.json b/vscode/extensions.json new file mode 100644 index 0000000..6f43801 --- /dev/null +++ b/vscode/extensions.json @@ -0,0 +1 @@ +["davidanson.vscode-markdownlint","esbenp.prettier-vscode","github.copilot","github.copilot-chat","ms-azuretools.vscode-docker","ms-vscode-remote.remote-containers","vscode-icons-team.vscode-icons"] diff --git a/vscode/settings.json b/vscode/settings.json index aa887d4..2ef7c69 100755 --- a/vscode/settings.json +++ b/vscode/settings.json @@ -10,4 +10,5 @@ "scminput": false }, "git.autofetch": true, + "workbench.iconTheme": "vscode-icons", } \ No newline at end of file