Skip to content

Commit

Permalink
Merge pull request #63 from StrangeRanger/dev
Browse files Browse the repository at this point in the history
Seval major changes to the text and 'under-the-hood' script changes
  • Loading branch information
StrangeRanger authored Nov 19, 2024
2 parents 71cbc52 + 4d5382d commit 722f917
Show file tree
Hide file tree
Showing 10 changed files with 157 additions and 67 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/update_from_submodule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Update Submodule Changes

# Trigger the workflow on push events to Dependabot branches
on:
push:
branches:
- 'dependabot/**'

jobs:
update-file-after-submodule:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: true

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Run Update Script
run: |
chmod +x ./update_repo.py
./update_repo.py
- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "[email protected]"
# Step 5: Commit the changes if there are any
- name: Commit Changes
run: |
git add .
git commit -m "Update file after submodule update" || echo "No changes to commit"
- name: Push Changes
run: |
git push origin HEAD:update-file-after-submodule
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
#token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Update file after submodule update"
title: "Update File After Submodule Update"
body: |
This pull request updates the relevant files after a submodule update by Dependabot.
base: main
head: update-file-after-submodule

15 changes: 2 additions & 13 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
{
"cSpell.words": [
"betterem",
"Hilite",
"inlinehilite",
"linenums",
"matomo",
"mkdocs",
"nvim",
"pygments",
"pymdown",
"pymdownx",
"smartsymbols",
"superfences",
"viewports"
"Neovim",
"nvim"
]
}
43 changes: 30 additions & 13 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,19 @@ The **TPPM** section features programs that can be installed using package manag
The **NPM** section lists programs that can be installed using the system's default package manager. Since the primary Debian- and Arch-based Linux based distributions, all the programs in this section are confirmed to be installable via `apt` or `pacman`. For other Linux distributions, you can check [Repology](https://repology.org/) to see if the program is available in your distribution's package manager. Similar to the **TPPM** section, I've included additional information such as a brief description for each program and a link to its Repology page.

/// tab | Third Party Package Manager

{{ read_csv("includes/csv/useful-packages-tppm.csv") }}

///

/// tab | Native Package Manager
Applicable Operating Systems: Linux

{{ read_csv("includes/csv/useful-packages-npm.csv") }}

///

## Customizing ZSH Shell
## Customizing ZSH

### Framework

Expand All @@ -39,83 +42,97 @@ Applicable Operating Systems: Linux

### Shell Theme

In combination with oh-my-zsh, I use [Starship](https://github.com/starship/starship) [Powerlevel10k](https://github.com/romkatv/powerlevel10k) as my shell theme. Starship is a fast, minimal, and customizable shell prompt that displays information about the current directory, git branch, and other relevant details. It is written in Rust, making it extremely fast and lightweight.
In combination with oh-my-zsh, I use [Starship](https://github.com/starship/starship) as my shell theme. Starship is a fast, minimal, and highly customizable shell prompt that displays information about the current directory, git branch, and other relevant details. It is written in Rust, making it extremely fast and lightweight.

As a note, I previously used [Powerlevel10k](https://github.com/romkatv/powerlevel10k), which is another **excellent** shell theme. However, as of May 21, 2024, Powerlevel10k has entered a ["life support" mode](https://github.com/romkatv/powerlevel10k/commit/bde5ca4c2aa6e0c52dd7f15cf216dffdb1ec788c). In the maintainer's words, "The project has very limited support", with "no new features are in the works", "most bugs will go unfixed", and "help requests will be ignored". As such, I decided to switch to a project that is actively maintained and has a bright future ahead of it.
As a note, I previously used [Powerlevel10k](https://github.com/romkatv/powerlevel10k), which is another **excellent** shell theme. However, as of May 21, 2024, Powerlevel10k has entered a ["life support" mode](https://github.com/romkatv/powerlevel10k/commit/bde5ca4c2aa6e0c52dd7f15cf216dffdb1ec788c). In the maintainer's words, "The project has very limited support", with "no new features are in the works", "most bugs will go unfixed", and "help requests will be ignored". As such, I decided to switch to an actively maintained project and mature alternative, Starship.

### ZSH Resource File

Below are the configurations for my `.zshrc` file, divided into two sections: macOS and Linux. The macOS configurations are tailored for macOS, while the other is designed for Linux.
Below are the configurations for my `.zshrc` file, divided into two sections: one for macOS and one for Linux. Each section is tailored to its respective operating system.

You are welcome to use this resource in any manner you prefer. My intention is to offer it as a guide for structuring your own `.zshrc` file and to present additional configurations not detailed elsewhere in this document.
You're welcome to use this resource however you like. My intention is to offer it as a guide for structuring your own `.zshrc` file and to present additional configurations not detailed elsewhere in this document.

/// details | My ZSH Resource File
//// tab | macOS

```bash title=".zshrc"
--8<-- "includes/zshrc-files/zshrc-macos.zsh"
```

////

//// tab | Linux

```bash title=".zshrc"
--8<-- "includes/zshrc-files/zshrc-linux.zsh"
```

////
///

#### Oh-my-zsh Plugins

This is a list of all the oh-my-zsh plugins that I use and find to provide useful functionality.
Below is a list of all the oh-my-zsh plugins that I use and find particularly useful.

{{ read_csv("includes/csv/oh-my-zsh-plugins.csv") }}

#### Custom Aliases

Below is a list of aliases that are in my `.zshrc` files. They are broken up into two groups: Group 1 and Group 2. Group 1 contains general aliases, while Group 2 contains aliases listing categorized commands. Most of these commands are programs mentioned in [Useful Programs](#useful-programs), that I don't frequently use, but still want to have quick access to.
Below is a list of aliases from my `.zshrc` files, organized into two groups: Group 1 and Group 2. Group 1 contains general aliases, while Group 2 includes aliases for categorized commands. Many of these commands are programs mentioned in the [Useful Programs](#useful-programs) section that I don't use frequently but still want quick access to.

/// tab | macOS

```bash title=".zshrc"
--8<-- "includes/zshrc-files/zshrc-macos-snippet.zsh:user_config"
```

///

/// tab | Linux

```bash title=".zshrc"
--8<-- "includes/zshrc-files/zshrc-linux-snippet.zsh:user_config"
```

///

### Modifying CLI Colors

The terminal colors that are used for folders, files, and other items in the command line interface can be customized using the `LS_COLORS` (macOS & Linux) and `LSCOLORS` (macOS) environment variables. If you want to modify these colors, you can do so by setting the `LS_COLORS` or `LSCOLORS` variable in your `.zshrc` file.
You can customize the terminal colors for folders, files, and other items in the terminal by setting the `LS_COLORS` (Linux & macOS) or `LSCOLORS` (macOS) environment variables. To modify these colors, add the appropriate `LS_COLORS` or `LSCOLORS` variable to your `.zshrc` file.

/// details | LS_COLORS & LSCOLORS Explained
On macOS, both `LSCOLORS` and `LS_COLORS` are necessary for specifying terminal colors. `LSCOLORS` is used for commands like `ls`, determining the colors in the command line interface, whereas `LS_COLORS` is used by zsh for similar purposes. In contrast, Linux only requires `LS_COLORS`, which is employed by both the `ls` command and zsh.

The underlying reason for this difference lies in the distinct versions of the `ls` command on macOS (FreeBSD version) and Linux (GNU version). macOS's `ls` command relies on `LSCOLORS` for color settings, while Linux uses `LS_COLORS`, each with its unique formatting. Moreover, since zsh recognizes only the `LS_COLORS` format, it's imperative to use it on macOS to ensure proper display and functionality of CLI colors.
On macOS, both `LSCOLORS` and `LS_COLORS` are necessary for specifying terminal colors. The `LSCOLORS` environment variable is used by commands like `ls` to determine the colors displayed in the terminal, while `LS_COLORS` is used by zsh for similar purposes. In contrast, Linux only requires `LS_COLORS`, which is utilized by both commands like `ls` and zsh.

This difference arises from the distinct versions of the `ls` command on macOS and Linux. macOS employs the FreeBSD version of `ls`, which relies on `LSCOLORS` for color settings, whereas Linux uses the GNU version, which depends on `LS_COLORS`. Each variable has its own unique formatting. Additionally, since zsh recognizes only the `LS_COLORS` format, it's important to set this variable on macOS to ensure proper display and functionality of CLI colors.

Included below is a key that explains the values of `LSCOLORS` and `LS_COLORS` in my configurations:

{{ read_csv("includes/csv/cli-colors-explained.csv") }}

For an in-depth understanding of LS_COLORS and LSCOLORS, I recommend visiting this [gist](https://gist.github.com/thomd/7667642).
For an in-depth understanding of `LS_COLORS` and `LSCOLORS`, I recommend visiting this [gist](https://gist.github.com/thomd/7667642).

///

Below are my configurations for both macOS and Linux systems. To apply these settings, simply insert the following code into your `~/.zshrc` file:
Below are my configurations for both macOS and Linux systems. To apply these settings, simply add the following code to your `~/.zshrc` file:

/// tab | macOS

```bash title="CLI Color Configuration"
--8<-- "includes/zshrc-files/zshrc-macos-snippet.zsh:ls_colors"
```

///

/// tab | Linux

```bash title="CLI Color Configuration"
--8<-- "includes/zshrc-files/zshrc-linux-snippet.zsh:ls_colors"
```

///

You can additionally modify the shading and appearance of the CLI colors by adjusting the ANSI-color scheme in your terminal profile. This can be done manually, with guides available for both [macOS](https://support.apple.com/guide/terminal/change-profiles-text-preferences-trmltxt/mac) and [Linux](https://help.gnome.org/users/gnome-terminal/stable/app-colors.html.en) (gnome specific instructions). Alternatively, you can use my custom profile schemes, which are detailed in the [Terminal Profile](#terminal-profile) section.
You can further modify the shading and appearance of CLI colors by adjusting the ANSI color scheme in your terminal profile. This can be done manually, with guides available for both [macOS](https://support.apple.com/guide/terminal/change-profiles-text-preferences-trmltxt/mac) and [Linux](https://help.gnome.org/users/gnome-terminal/stable/app-colors.html.en) (specific to GNOME). Alternatively, you can use my custom profile schemes, which are detailed in the [Terminal Profile](#terminal-profile) section.

## Neovim Resource File

Expand Down
6 changes: 3 additions & 3 deletions includes/csv/oh-my-zsh-plugins.csv
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Plugins,Description,Is a Command,Other Info
[git](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/git),The git plugin provides many aliases and a few useful functions,Collection," "
[colored-man-pages](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/colored-man-pages),Adds colors to man pages,No," "
[copybuffer](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/copybuffer),"Allows you to copy what you are currently typing, via ++ctrl+'O'++",Yes,Key Combination: ++ctrl+'O'++
[copybuffer](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/copybuffer),"Allows you to copy what you are currently typing, via ++ctrl+'O'++",Yes/No,Key Combination: ++ctrl+'O'++
[copypath](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/copypath),Copies the path of your working directory,Yes," "
[copyfile](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/copyfile),Copies the contents of a file,Yes," "
[bgnotify](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/bgnotify),cross-platform background notifications for long running commands,No,[Extra install instructions](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/bgnotify)
[bgnotify](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/bgnotify),cross-platform background notifications for long running commands,Yes/No,[Extra install instructions](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/bgnotify)
[command-not-found](https://github.com/ohmyzsh/ohmyzsh/blob/master/plugins/command-not-found/README.md),This plugin uses the command-not-found package for zsh to provide suggested packages to be installed if a command cannot be found.,No," "
2 changes: 2 additions & 0 deletions includes/zshrc-files/zshrc-linux-snippet.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,6 @@ ugit - ugit helps you undo git commands without much effort.
# Modifies the colors of files and directories in the terminal.
export LS_COLORS="di=34:ln=36:so=35:pi=1;33:ex=32:bd=34;46:cd=1;33;40:su=30;41:sg=30;46:tw=30;42:ow=30;1;43"

# Set list-colors to enable filename colorizing.
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
# --8<-- [end:ls_colors]
2 changes: 2 additions & 0 deletions includes/zshrc-files/zshrc-macos-snippet.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,6 @@ export LSCOLORS="exgxfxDxcxegDaabagacaD"
## here: https://github.com/ohmyzsh/ohmyzsh/issues/6060#issuecomment-327934559
export LS_COLORS="di=34:ln=36:so=35:pi=1;33:ex=32:bd=34;46:cd=1;33;40:su=30;41:sg=30;46:tw=30;42:ow=30;1;43"

# Set list-colors to enable filename colorizing.
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
# --8<-- [end:ls_colors]
36 changes: 24 additions & 12 deletions update_repo.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
#!/usr/bin/env python3
#
# NOTE:
# - This script does not require the initialization of a virtual environment. The
# Pipfiles are only required when deploying the MkDocs site.
# - This script has some hard-coded values that may make it fragile in some cases.
# I've attempted to do my best an indicate where these values are, but it's always a
# good idea to keep an eye on this script when making changes to the configuration.
#
########################################################################################
"""
Automates the process of updating zsh and neovim configuration files in the 'includes'
directory. This is done by reading my 'dotfiles' in the 'submodules/dotfiles' submodule
and applying the necessary changes to the 'includes' directory.
NOTE:
This script does not require the initialization of a virtual environment. The
Pipfiles are only required when deploying the MkDocs site.
"""
# [ Imports ]###########################################################################

from utils.config import (

from utils.file_utils import read_file, write_file
from utils.constants import (
CHEZMOI_STATEMENTS,
MKDOCS_SECTION_MARKERS,
NEOVIM_CONFIG_PATHS,
ZSH_CONFIG_PATHS,
NEOVIM_MARKERS,
ZSH_ALIAS_MARKERS,
ZSH_LS_COLORS_MARKERS,
MKDOCS_USER_CONFIG_MARKERS,
MKDOCS_LS_COLORS_MARKERS,
)
from utils.file_utils import read_file, write_file
from utils.marker_config import NEOVIM_MARKERS, ZSH_ALIAS_MARKERS, ZSH_LS_COLORS_MARKERS


# [ Functions ]#########################################################################

Expand Down Expand Up @@ -101,23 +111,25 @@ def zsh_config():

if ZSH_ALIAS_MARKERS.start_marker in line:
ZSH_ALIAS_MARKERS.is_within_section = True
output_data.append(MKDOCS_SECTION_MARKERS["user_config_start"] + "\n")
output_data.append(MKDOCS_USER_CONFIG_MARKERS.start_marker)
elif ZSH_LS_COLORS_MARKERS.start_marker in line:
ZSH_LS_COLORS_MARKERS.is_within_section = True
output_data.append(MKDOCS_SECTION_MARKERS["ls_colors_start"] + "\n")
output_data.append(MKDOCS_LS_COLORS_MARKERS.start_marker)

if (
ZSH_ALIAS_MARKERS.end_marker in line
and ZSH_ALIAS_MARKERS.is_within_section
):
ZSH_ALIAS_MARKERS.is_within_section = False
output_data.append(MKDOCS_SECTION_MARKERS["user_config_end"] + "\n")
output_data.append(MKDOCS_USER_CONFIG_MARKERS.end_marker)
elif (
ZSH_LS_COLORS_MARKERS.end_marker in line
and ZSH_LS_COLORS_MARKERS.is_within_section
):
ZSH_LS_COLORS_MARKERS.is_within_section = False
output_data.append(MKDOCS_SECTION_MARKERS["ls_colors_end"] + "\n")
if ZSH_LS_COLORS_MARKERS.hard_coded_inclusion:
output_data.extend(ZSH_LS_COLORS_MARKERS.hard_coded_inclusion)
output_data.append(MKDOCS_LS_COLORS_MARKERS.end_marker)

if (
ZSH_ALIAS_MARKERS.is_within_section
Expand Down
3 changes: 3 additions & 0 deletions utils/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
__version__ = "1.0.2"
__author__ = "Hunter T. (StrangeRanger)"
__license__ = "MIT"
40 changes: 33 additions & 7 deletions utils/config.py → utils/constants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from pathlib import Path
from utils.marker_config import Markers

CHEZMOI_STATEMENTS = ["{{ ", "{{- "]

NEOVIM_CONFIG_PATHS = {
"init_lua": {
Expand Down Expand Up @@ -34,11 +37,34 @@
},
}

MKDOCS_SECTION_MARKERS = {
"user_config_start": "# --8<-- [start:user_config]",
"user_config_end": "# --8<-- [end:user_config]",
"ls_colors_start": "# --8<-- [start:ls_colors]",
"ls_colors_end": "# --8<-- [end:ls_colors]",
}
NEOVIM_MARKERS = Markers(
start_marker='""""[ General Configurations ]',
end_marker='""""[ vim-plug Plugin Configurations ]',
)

CHEZMOI_STATEMENTS = ["{{ ", "{{- "]
ZSH_ALIAS_MARKERS = Markers(
start_marker="####[[ Aliases ]]",
end_marker="####[[ Environmental Variables ]]",
)

# NOTE: This is an "estimated" value, that relies on the position of comments and other
# commands that may not always be present. Compared to the previous markers, this one
# is more likely to be wrong, if the `.zshrc` related files are modified.
ZSH_LS_COLORS_MARKERS = Markers(
start_marker="# Modifies the colors",
end_marker="## Set default",
hard_coded_inclusion=(
"# Set list-colors to enable filename colorizing.\n",
"zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}\n",
),
)

MKDOCS_USER_CONFIG_MARKERS = Markers(
start_marker="# --8<-- [start:user_config]\n",
end_marker="# --8<-- [end:user_config]\n",
)

MKDOCS_LS_COLORS_MARKERS = Markers(
start_marker="# --8<-- [start:ls_colors]\n",
end_marker="# --8<-- [end:ls_colors]\n",
)
23 changes: 4 additions & 19 deletions utils/marker_config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from dataclasses import dataclass
from typing import Optional, Tuple


@dataclass
Expand All @@ -8,28 +9,12 @@ class Markers:
Attributes:
start_marker (str): The starting marker for the section.
end_marker (str): The ending marker for the section.
hard_coded_inclusion (Optional[Tuple[str, ...]]): Hard-coded lines to include
in the section.
is_within_section (bool): Whether the current line is within the section.
"""

start_marker: str
end_marker: str
hard_coded_inclusion: Optional[Tuple[str, ...]] = None
is_within_section: bool = False


NEOVIM_MARKERS = Markers(
start_marker='""""[ General Configurations ]',
end_marker='""""[ vim-plug Plugin Configurations ]',
)

ZSH_ALIAS_MARKERS = Markers(
start_marker="####[[ Aliases ]]",
end_marker="####[[ Environmental Variables ]]",
)

# NOTE: This is an "estimated" value, that relies on the position of comments and other
# commands that may not always be present. Compared to the previous markers, this one
# is more likely to be wrong, if the `.zshrc` related files are modified.
ZSH_LS_COLORS_MARKERS = Markers(
start_marker="# Modifies the colors",
end_marker="## Set default",
)

0 comments on commit 722f917

Please sign in to comment.