diff --git a/.editorconfig b/.editorconfig index beeff9f..3d9a987 100644 --- a/.editorconfig +++ b/.editorconfig @@ -16,6 +16,3 @@ function_next_line = false [*.py] indent_size = 4 - -[.gdbinit] -trim_trailing_whitespace = false diff --git a/.gdbinit b/.gdbinit deleted file mode 100644 index 6050218..0000000 --- a/.gdbinit +++ /dev/null @@ -1,164 +0,0 @@ -# https://sourceware.org/gdb/current/onlinedocs/gdb.html/Prompt.html#Prompt -set prompt \033[38;5;177mgdb\033[0m$ -# https://sourceware.org/gdb/current/onlinedocs/gdb.html/Messages_002fWarnings.html#Messages_002fWarnings -set confirm off -# https://sourceware.org/gdb/current/onlinedocs/gdb.html/Screen-Size.html#Screen-Size -set pagination off -# https://sourceware.org/gdb/current/onlinedocs/gdb.html/Command-History.html#Command-History -set history save on -set history expansion on - -# https://sourceware.org/gdb/current/onlinedocs/gdb.html/Machine-Code.html#Machine-Code -set disassembly-flavor intel - -# https://sourceware.org/gdb/current/onlinedocs/gdb.html/Define.html#Define -define cls -shell clear -end -document cls -clear the screen -end - -# https://sourceware.org/gdb/current/onlinedocs/gdb.html/Hooks.html#Hooks -define hook-stop -end - -set $COLOR_RED = "\e[30;1;31m" -set $COLOR_GREEN = "\e[30;1;32m" -set $COLOR_YELLOW = "\e[30;1;33m" -set $COLOR_BLUE = "\e[30;1;34m" -set $COLOR_MAGENTA = "\e[30;1;35m" -set $COLOR_RESET = "\e[0m" - -define print_register -if ($argc % 4 == 0) - set $_rows = 4 -end - -if ($argc % 5 == 0) - set $_rows = 5 -end - -set $_blocks = ($argc / $_rows) - 1 - -set $_i = 0 -set $_j = 0 - -# 64-bit registers -while ($_i < $_blocks) - eval "set $_name = $arg%d", $_j - eval "set $_r64_%d = (long)$%s", $_i, $_name - eval "set $_r64 = $_r64_%d", $_i - printf "%4s %s%016lx%s %-20ld\t", $_name, $COLOR_BLUE, $_r64, $COLOR_RESET, $_r64 - set $_i++ - set $_j++ -end -eval "set $_name = $arg%d", $_j -eval "set $_r64_%d = (long)$%s", $_i, $_name -eval "set $_r64 = $_r64_%d", $_i -printf "%4s %s%016lx%s %-20ld\n", $_name, $COLOR_BLUE, $_r64, $COLOR_RESET, $_r64 -set $_i = 0 -set $_j++ - -# 32-bit registers -while ($_i < $_blocks) - eval "set $_name = $arg%d", $_j - eval "set $_r32h_%d = $_r64_%d >> 32", $_i, $_i - eval "set $_r32h = $_r32h_%d", $_i - eval "set $_r32l_%d = $_r64_%d & 0xffffffff", $_i, $_i - eval "set $_r32l = $_r32l_%d", $_i - printf "%4s %08x%s%08x%s %-20u\t", $_name, $_r32h, $COLOR_BLUE, $_r32l, $COLOR_RESET, $_r32l - set $_i++ - set $_j++ -end -eval "set $_name = $arg%d", $_j -eval "set $_r32h_%d = $_r64_%d >> 32", $_i, $_i -eval "set $_r32h = $_r32h_%d", $_i -eval "set $_r32l_%d = $_r64_%d & 0xffffffff", $_i, $_i -eval "set $_r32l = $_r32l_%d", $_i -printf "%4s %08x%s%08x%s %-20u\n", $_name, $_r32h, $COLOR_BLUE, $_r32l, $COLOR_RESET, $_r32l -set $_i = 0 -set $_j++ - -# 16-bit registers -while ($_i < $_blocks) - eval "set $_name = $arg%d", $_j - eval "set $_r32h = $_r32h_%d", $_i - eval "set $_r16h_%d = $_r32l_%d >> 16", $_i, $_i - eval "set $_r16h = $_r16h_%d", $_i - eval "set $_r16l_%d = $_r32l_%d & 0xffff", $_i, $_i - eval "set $_r16l = $_r16l_%d", $_i - printf "%4s %08x%04x%s%04x%s %-20u\t", $_name, $_r32h, $_r16h, $COLOR_BLUE, $_r16l, $COLOR_RESET, $_r16l - set $_i++ - set $_j++ -end -eval "set $_name = $arg%d", $_j -eval "set $_r32h = $_r32h_%d", $_i -eval "set $_r16h_%d = $_r32l_%d >> 16", $_i, $_i -eval "set $_r16h = $_r16h_%d", $_i -eval "set $_r16l_%d = $_r32l_%d & 0xffff", $_i, $_i -eval "set $_r16l = $_r16l_%d", $_i -printf "%4s %08x%04x%s%04x%s %-20u\n", $_name, $_r32h, $_r16h, $COLOR_BLUE, $_r16l, $COLOR_RESET, $_r16l -set $_i = 0 -set $_j++ - -if ($_rows == 5) - # Upper 8-bit registers - while ($_i < $_blocks) - eval "set $_name = $arg%d", $_j - eval "set $_r32h = $_r32h_%d", $_i - eval "set $_r16h = $_r16h_%d", $_i - eval "set $_r8h = $_r16l_%d >> 8", $_i - eval "set $_r8l = $_r16l_%d & 0xff", $_i - printf "%4s %08x%04x%s%02x%s%02x %-20u\t", $_name, $_r32h, $_r16h, $COLOR_BLUE, $_r8h, $COLOR_RESET, $_r8l, $_r8h - set $_i++ - set $_j++ - end - eval "set $_name = $arg%d", $_j - eval "set $_r32h = $_r32h_%d", $_i - eval "set $_r16h = $_r16h_%d", $_i - eval "set $_r8h = $_r16l_%d >> 8", $_i - eval "set $_r8l = $_r16l_%d & 0xff", $_i - printf "%4s %08x%04x%s%02x%s%02x %-20u\n", $_name, $_r32h, $_r16h, $COLOR_BLUE, $_r8h, $COLOR_RESET, $_r8l, $_r8h - set $_i = 0 - set $_j++ -end - -# Lower 8-bit registers -while ($_i < $_blocks) - eval "set $_name = $arg%d", $_j - eval "set $_r32h = $_r32h_%d", $_i - eval "set $_r16h = $_r16h_%d", $_i - eval "set $_r8h = $_r16l_%d >> 8", $_i - eval "set $_r8l = $_r16l_%d & 0xff", $_i - printf "%4s %08x%04x%02x%s%02x%s %-20u\t", $_name, $_r32h, $_r16h, $_r8h, $COLOR_BLUE, $_r8l, $COLOR_RESET, $_r8l - set $_i++ - set $_j++ -end -eval "set $_name = $arg%d", $_j -eval "set $_r32h = $_r32h_%d", $_i -eval "set $_r16h = $_r16h_%d", $_i -eval "set $_r8h = $_r16l_%d >> 8", $_i -eval "set $_r8l = $_r16l_%d & 0xff", $_i -printf "%4s %08x%04x%02x%s%02x%s %-20u\n", $_name, $_r32h, $_r16h, $_r8h, $COLOR_BLUE, $_r8l, $COLOR_RESET, $_r8l -end - -define registers -print_register "rax" "rcx" "rdx" "rbx" "eax" "ecx" "edx" "ebx" "ax" "cx" "dx" "bx" "ah" "ch" "dh" "bh" "al" "cl" "dl" "bl" -echo \n -print_register "rsp" "rbp" "rsi" "rdi" "esp" "ebp" "esi" "edi" "sp" "bp" "si" "di" "spl" "bpl" "sil" "dil" -echo \n -print_register "r8" "r9" "r10" "r11" "r8d" "r9d" "r10d" "r11d" "r8w" "r9w" "r10w" "r11w" "r8b" "r9b" "r10b" "r11b" -echo \n -print_register "r12" "r13" "r14" "r15" "r12d" "r13d" "r14d" "r15d" "r12w" "r13w" "r14w" "r15w" "r12b" "r13b" "r14b" "r15b" -end -document registers -print registers information to the screen -end - -define context -printf "--------------------------------- [registers]\n" -end -document context -print context information to the screen -end diff --git a/.github/workflows/analysis.yaml b/.github/workflows/analysis.yaml index 8226f28..6b8ca41 100644 --- a/.github/workflows/analysis.yaml +++ b/.github/workflows/analysis.yaml @@ -17,4 +17,4 @@ jobs: uses: actions/checkout@v3.5.3 - name: Running ShellCheck - run: ./scripts/lint.sh + run: ./scripts/shellcheck.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c978956 --- /dev/null +++ b/.gitignore @@ -0,0 +1,159 @@ +# Python.gitignore +# https://github.com/github/gitignore/blob/main/Python.gitignore + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +# Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +# poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +# pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# Other stuff +.gdb_history diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..0c7d5f5 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.11.4 diff --git a/.rsyncignore b/.rsyncignore index ba2a2a1..1200fe3 100644 --- a/.rsyncignore +++ b/.rsyncignore @@ -1,10 +1,3 @@ .git/ .github/ -scripts/ -.gitignore -.gitmodules -.rsyncignore -bootstrap.sh -Microsoft.PowerShell_profile.ps1 -setup.reg -texlive2023profile +.venv/ diff --git a/bootstrap.sh b/bootstrap.sh index c54ba9a..91c1c75 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -5,14 +5,16 @@ root="$( pwd -P )" declare -r root +declare -r unix="$root/unix" shopt -s expand_aliases -source "$root/.bash_aliases" +# shellcheck source=./unix/.bash_aliases +source "$unix/.bash_aliases" __bootstrap() { # https://manpages.debian.org/rsync/rsync - rsync --no-perms --archive --verbose --human-readable --exclude-from="$root/.rsyncignore" "$root/" "$HOME" + rsync --no-perms --archive --verbose --human-readable --safe-links --copy-links --exclude-from="$root/.rsyncignore" "$unix/" "$HOME" if type -f nvim > /dev/null 2>&1; then __bootstrap_nvim @@ -27,32 +29,30 @@ __bootstrap_nvim() { local -r nvim_config_home="${MAPFILE[0]}" local -r default_nvim_config_home="$HOME/.config/nvim" - local -r local_nvim_config_home="$root/.config/nvim" + local -r local_nvim_config_home="$unix/.config/nvim" local -r nvim_data_home="${MAPFILE[1]}" local -r default_nvim_data_home="$HOME/.local/share/nvim" - local -r local_nvim_data_home="$root/.local/share/nvim" + local -r local_nvim_data_home="$unix/.local/share/nvim" if [[ -d $local_nvim_config_home && $default_nvim_config_home != "$nvim_config_home" ]]; then cat << EOF [Neovim] Detected a non-default ($default_nvim_config_home) config directory, also copying files to: $nvim_config_home -[Neovim] See https://neovim.io/doc/user/starting.html#standard-path - +[Neovim] See: https://neovim.io/doc/user/starting.html#standard-path EOF - rsync --no-perms --archive --verbose --human-readable "$default_nvim_config_home/" "$nvim_config_home" + rsync --no-perms --archive --safe-links --copy-links --human-readable "$default_nvim_config_home/" "$nvim_config_home" fi if [[ -d $local_nvim_data_home && $default_nvim_data_home != "$nvim_data_home" ]]; then cat << EOF [Neovim] Detected a non-default ($default_nvim_data_home) data directory, also copying files to: $nvim_data_home -[Neovim] See https://neovim.io/doc/user/starting.html#standard-path - +[Neovim] See: https://neovim.io/doc/user/starting.html#standard-path EOF - rsync --no-perms --archive --verbose --human-readable "$default_nvim_data_home/" "$nvim_data_home" + rsync --no-perms --archive --safe-links --copy-links --human-readable "$default_nvim_data_home/" "$nvim_data_home" fi } diff --git a/texlive2023profile b/misc/texlive2023profile similarity index 100% rename from texlive2023profile rename to misc/texlive2023profile diff --git a/pyright.json b/pyright.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/pyright.json @@ -0,0 +1 @@ +{} diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..82c4485 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +black==23.7.0 +pyright==1.1.317 diff --git a/scripts/format.sh b/scripts/format.sh index 46f63ca..80e720a 100755 --- a/scripts/format.sh +++ b/scripts/format.sh @@ -5,7 +5,8 @@ root="$( pwd -P )" declare -r root +declare -r unix="$root/unix" -shfmt -w "$root" "$root/.bash_aliases" "$root/.bash_logout" "$root/.bashrc" "$root/.profile" +shfmt -w "$root" "$unix/.bash_aliases" "$unix/.bash_logout" "$unix/.bashrc" "$unix/.profile" -stylua "$root/.config/nvim" +stylua "$unix/.config/nvim" diff --git a/scripts/lint.sh b/scripts/lint.sh deleted file mode 100755 index 20c48b8..0000000 --- a/scripts/lint.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash - -root="$( - cd "$(dirname "${BASH_SOURCE[0]}")/.." > /dev/null 2>&1 || exit - pwd -P -)" -declare -r root - -shellcheck --external-sources "$root"/*.sh "$root"/scripts/*.sh "$root"/.local/bin/*.sh \ - "$root/.bash_aliases" "$root/.bash_logout" "$root/.bashrc" "$root/.profile" diff --git a/scripts/shellcheck.sh b/scripts/shellcheck.sh new file mode 100755 index 0000000..b944834 --- /dev/null +++ b/scripts/shellcheck.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +root="$( + cd "$(dirname "${BASH_SOURCE[0]}")/.." > /dev/null 2>&1 || exit + pwd -P +)" +declare -r root +declare -r unix="$root/unix" + +shellcheck --external-sources "$root"/**/*.sh "$unix"/.local/**/*.sh \ + "$unix/.bash_aliases" "$unix/.bash_logout" "$unix/.bashrc" "$unix/.profile" diff --git a/.bash_aliases b/unix/.bash_aliases similarity index 100% rename from .bash_aliases rename to unix/.bash_aliases diff --git a/.bash_logout b/unix/.bash_logout similarity index 100% rename from .bash_logout rename to unix/.bash_logout diff --git a/.bashrc b/unix/.bashrc similarity index 100% rename from .bashrc rename to unix/.bashrc diff --git a/.config/nvim/init.lua b/unix/.config/nvim/init.lua similarity index 98% rename from .config/nvim/init.lua rename to unix/.config/nvim/init.lua index af5e6eb..ef80187 100644 --- a/.config/nvim/init.lua +++ b/unix/.config/nvim/init.lua @@ -1,4 +1,4 @@ -require('plugins') +require("plugins") local lsp = require("lsp-zero").preset({}) diff --git a/.config/nvim/lua/plugins.lua b/unix/.config/nvim/lua/plugins.lua similarity index 100% rename from .config/nvim/lua/plugins.lua rename to unix/.config/nvim/lua/plugins.lua diff --git a/unix/.editorconfig b/unix/.editorconfig new file mode 120000 index 0000000..38d9a0c --- /dev/null +++ b/unix/.editorconfig @@ -0,0 +1 @@ +../.editorconfig \ No newline at end of file diff --git a/unix/.gdbinit b/unix/.gdbinit new file mode 100644 index 0000000..909ce0c --- /dev/null +++ b/unix/.gdbinit @@ -0,0 +1,29 @@ +python +import gdbconfig +end + +# https://sourceware.org/gdb/current/onlinedocs/gdb.html/Prompt.html#Prompt +# set prompt \033[38;5;177mgdb\033[0m$ +# https://sourceware.org/gdb/current/onlinedocs/gdb.html/Messages_002fWarnings.html#Messages_002fWarnings +set confirm off +set verbose off +# https://sourceware.org/gdb/current/onlinedocs/gdb.html/Screen-Size.html#Screen-Size +set pagination off +# https://sourceware.org/gdb/current/onlinedocs/gdb.html/Command-History.html#Command-History +set history save on +set history expansion on +# https://sourceware.org/gdb/current/onlinedocs/gdb.html/Print-Settings.html#Print-Settings +set print pretty on +set print array off +set print array-indexes on +# https://sourceware.org/gdb/current/onlinedocs/gdb.html/Machine-Code.html#Machine-Code +set disassembly-flavor intel +# https://sourceware.org/gdb/current/onlinedocs/gdb.html/Python-Commands.html#Python-Commands +set python print-stack full + +define cls +shell clear +end +document cls +clear the screen +end diff --git a/.gitconfig b/unix/.gitconfig similarity index 100% rename from .gitconfig rename to unix/.gitconfig diff --git a/.local/bin/install-ccache.sh b/unix/.local/bin/install-ccache.sh similarity index 100% rename from .local/bin/install-ccache.sh rename to unix/.local/bin/install-ccache.sh diff --git a/.profile b/unix/.profile similarity index 100% rename from .profile rename to unix/.profile diff --git a/unix/.shellcheckrc b/unix/.shellcheckrc new file mode 120000 index 0000000..31ea49a --- /dev/null +++ b/unix/.shellcheckrc @@ -0,0 +1 @@ +../.shellcheckrc \ No newline at end of file diff --git a/unix/gdb_config.py b/unix/gdb_config.py new file mode 100644 index 0000000..3e181e6 --- /dev/null +++ b/unix/gdb_config.py @@ -0,0 +1,51 @@ +import gdb # pyright: ignore [reportMissingModuleSource] +import os +import sys + + +class Dashboard(gdb.Command): + def __init__(self): + super().__init__("dashboard", gdb.COMMAND_USER, gdb.COMPLETE_NONE, True) + + Dashboard.EnabledCommand(self) + + self.enabled = False + + gdb.events.stop.connect(self.on_stop) + + def invoke(self, arg, from_tty): + super().dont_repeat() + argv = gdb.string_to_argv(arg) + print(argv) + + def on_stop(self, event: "gdb.events.StopEvent"): + self.render() + + def render(self): + print("render") + pass + + class EnabledCommand(gdb.Command): + def __init__(self, dashboard: "Dashboard"): + super().__init__("dashboard enabled", gdb.COMMAND_USER) + self.dashboard = dashboard + + def invoke(self, arg, from_tty): + super().dont_repeat() + argv = gdb.string_to_argv(arg) + print(argv) + + +def get_terminal_size(fd=sys.stdout.fileno()): + return os.get_terminal_size(fd) + + +def custom_prompt(current_prompt: str): + # https://sourceware.org/gdb/current/onlinedocs/gdb.html/gdb_002eprompt.html#gdb_002eprompt + prompt = gdb.prompt.substitute_prompt(r"\[\e[38;5;177m\]gdb\[\e[0m\]$ ") + return prompt + + +gdb.prompt_hook = custom_prompt + +Dashboard() diff --git a/Microsoft.PowerShell_profile.ps1 b/windows/Microsoft.PowerShell_profile.ps1 similarity index 100% rename from Microsoft.PowerShell_profile.ps1 rename to windows/Microsoft.PowerShell_profile.ps1 diff --git a/setup.reg b/windows/setup.reg similarity index 100% rename from setup.reg rename to windows/setup.reg