From a746c9d8f633963add190ee92d708c304273fdb0 Mon Sep 17 00:00:00 2001 From: ivuorinen Date: Thu, 19 Jun 2025 00:20:52 +0000 Subject: [PATCH] Update cheatsheets --- tldr/dropdb | 42 +++++++++++++++++++++++++++++++++ tldr/exa | 2 +- tldr/komac | 41 ++++++++++++++++++++++++++++++++ tldr/linux/reflector | 4 ++-- tldr/linux/sed | 24 +++++++++++-------- tldr/linux/xdg-user-dir | 18 ++++++++++++++ tldr/linux/xdg-user-dirs-update | 1 + tldr/uv-help | 25 ++++++++++++++++++++ tldr/uv-lock | 37 +++++++++++++++++++++++++++++ tldr/uv-pip | 41 ++++++++++++++++++++++++++++++++ tldr/uv-remove | 33 ++++++++++++++++++++++++++ tldr/uv-run | 33 ++++++++++++++++++++++++++ tldr/uv-sync | 41 ++++++++++++++++++++++++++++++++ tldr/uv-venv | 29 +++++++++++++++++++++++ tldr/uv-version | 33 ++++++++++++++++++++++++++ 15 files changed, 391 insertions(+), 13 deletions(-) create mode 100644 tldr/dropdb create mode 100644 tldr/komac create mode 100644 tldr/linux/xdg-user-dir create mode 100644 tldr/uv-help create mode 100644 tldr/uv-lock create mode 100644 tldr/uv-pip create mode 100644 tldr/uv-remove create mode 100644 tldr/uv-run create mode 100644 tldr/uv-sync create mode 100644 tldr/uv-venv create mode 100644 tldr/uv-version diff --git a/tldr/dropdb b/tldr/dropdb new file mode 100644 index 00000000..35be3f99 --- /dev/null +++ b/tldr/dropdb @@ -0,0 +1,42 @@ +--- +syntax: markdown +tags: [tldr, common] +source: https://github.com/tldr-pages/tldr.git +--- +# dropdb + +> Remove a PostgreSQL database. +> A simple wrapper around the SQL command `DROP DATABASE`. +> More information: . + +- Destroy a database: + +`dropdb {{dbname}}` + +- Request a verification prompt before any destructive actions: + +`dropdb {{[-i|--interactive]}} {{database_name}}` + +- Connect with a specific username and destroy a database: + +`dropdb {{[-U|--username]}} {{username}} {{dbname}}` + +- Force a password prompt before connecting to the database: + +`dropdb {{[-W|--password]}} {{dbname}}}}` + +- Suppress a password prompt before connecting to the database: + +`dropdb {{[-w|--no-password]}} {{database_name}}` + +- Specify the server host name: + +`dropdb {{[-h|--host]}} {{host}} {{database_name}}` + +- Specify the server port: + +`dropdb {{[-p|--port]}} {{port}} {{database_name}}` + +- Attempt to terminate existing connections before destroying the database: + +`dropdb {{[-f|--force]}} {{database_name}}` diff --git a/tldr/exa b/tldr/exa index 397414b3..75006e5d 100644 --- a/tldr/exa +++ b/tldr/exa @@ -26,7 +26,7 @@ source: https://github.com/tldr-pages/tldr.git - Display a tree of files, three levels deep: -`exa {{[-l|--long]}} {[[-T|--tree]}} {{[-L|--level]}} {{3}}` +`exa {{[-l|--long]}} {{[-T|--tree]}} {{[-L|--level]}} {{3}}` - List files sorted by modification date (oldest first): diff --git a/tldr/komac b/tldr/komac new file mode 100644 index 00000000..78edc14b --- /dev/null +++ b/tldr/komac @@ -0,0 +1,41 @@ +--- +syntax: markdown +tags: [tldr, common] +source: https://github.com/tldr-pages/tldr.git +--- +# komac + +> Create WinGet manifests for the `winget-pkgs` repository. +> More information: . + +- Create a new package from scratch: + +`komac new {{Package.Identifier}} --version {{1.2.3}} --urls {{https://example.com/app.exe}}` + +- Update an existing package with a new version: + +`komac update {{Package.Identifier}} --version {{1.2.3}} --urls {{https://example.com/app.exe}}` + +- Update a package with multiple URLs and automatically submit: + +`komac update {{Package.Identifier}} --version {{1.2.3}} --urls {{https://example.com/app.exe https://example.com/app.msi ...}} --submit` + +- Remove a version from winget-pkgs: + +`komac remove {{Package.Identifier}} --version {{1.2.3}}` + +- List all versions for a package: + +`komac list-versions {{Package.Identifier}}` + +- Sync your fork of winget-pkgs with the upstream repository: + +`komac sync-fork` + +- Update the stored GitHub token: + +`komac token update --token {{your_github_token}}` + +- Generate shell autocompletion script: + +`komac complete {{bash|zsh|fish|powershell}}` diff --git a/tldr/linux/reflector b/tldr/linux/reflector index 5f52ea86..8c4fc698 100644 --- a/tldr/linux/reflector +++ b/tldr/linux/reflector @@ -14,11 +14,11 @@ source: https://github.com/tldr-pages/tldr.git - Only get German HTTPS mirrors: -`reflector --country {{Germany}} --protocol {{https}}` +`reflector {{[-c|--country]}} {{Germany}} {{[-p|--protocol]}} {{https}}` - Only get the 10 recently sync'd mirrors: -`reflector --latest {{10}}` +`reflector {{[-l|--latest]}} {{10}}` - Use a configuration file to fetch mirrors: diff --git a/tldr/linux/sed b/tldr/linux/sed index 247d5c13..06ec6964 100644 --- a/tldr/linux/sed +++ b/tldr/linux/sed @@ -5,34 +5,38 @@ source: https://github.com/tldr-pages/tldr.git --- # sed -> Edit text in a scriptable manner. +> GNU stream editor for filtering and transforming text. > See also: `awk`, `ed`. > More information: . -- Replace all `apple` (basic regex) occurrences with `mango` (basic regex) in all input lines and print the result to `stdout`: +- Replace `apple` with `mango` on all lines using basic regex, print to `stdout`: `{{command}} | sed 's/apple/mango/g'` -- Replace all `apple` (extended regex) occurrences with `APPLE` (extended regex) in all input lines and print the result to `stdout`: +- Replace `apple` with `APPLE` on all lines using extended regex, print to `stdout`: `{{command}} | sed {{[-E|--regexp-extended]}} 's/(apple)/\U\1/g'` -- Replace all `apple` (basic regex) occurrences with `mango` (basic regex) in a specific file and overwrite the original file in place: +- Use basic regex to replace `apple` with `mango` and `orange` with `lime` in-place in a file (overwriting original file): -`sed {{[-i|--in-place]}} 's/apple/mango/g' {{path/to/file}}` +`sed {{[-i|--in-place]}} -e 's/apple/mango/g' -e 's/orange/lime/g' {{path/to/file}}` -- Execute a specific script file and print the result to `stdout`: +- Execute a specific `sed` script file and print the result to `stdout`: `{{command}} | sed {{[-f|--file]}} {{path/to/script.sed}}` -- Print just the first line to `stdout`: +- [p]rint only the first line to `stdout`: `{{command}} | sed {{[-n|--quiet]}} '1p'` -- [d]elete the first line of a file: +- [d]elete lines 1 to 5 of a file and back up the original file with a `.orig` extension: -`sed {{[-i|--in-place]}} 1d {{path/to/file}}` +`sed {{[-i|--in-place=]}}{{.orig}} '1,5d' {{path/to/file}}` -- [i]nsert a new line at the first line of a file: +- [i]nsert a new line at the beginning of a file, overwriting the original file in-place: `sed {{[-i|--in-place]}} '1i\your new line text\' {{path/to/file}}` + +- Delete blank lines (with or without spaces/tabs) from a file, overwriting the original file in-place: + +`sed {{[-i|--in-place]}} '/^[[:space:]]*$/d' {{path/to/file}}` diff --git a/tldr/linux/xdg-user-dir b/tldr/linux/xdg-user-dir new file mode 100644 index 00000000..02c39f71 --- /dev/null +++ b/tldr/linux/xdg-user-dir @@ -0,0 +1,18 @@ +--- +syntax: markdown +tags: [tldr, linux] +source: https://github.com/tldr-pages/tldr.git +--- +# xdg-user-dir + +> Retrieve XDG user directory locations. +> See also: `xdg-user-dirs-update`. +> More information: . + +- Display the home directory for the current user: + +`xdg-user-dir` + +- Display the location of a user directory: + +`xdg-user-dir {{DESKTOP|DOWNLOAD|TEMPLATES|PUBLICSHARE|DOCUMENTS|MUSIC|PICTURES|VIDEOS}}` diff --git a/tldr/linux/xdg-user-dirs-update b/tldr/linux/xdg-user-dirs-update index 0ce6b2e5..53dd7e67 100644 --- a/tldr/linux/xdg-user-dirs-update +++ b/tldr/linux/xdg-user-dirs-update @@ -6,6 +6,7 @@ source: https://github.com/tldr-pages/tldr.git # xdg-user-dirs-update > Update XDG user directories. +> See also: `xdg-user-dir`. > More information: . - Change XDG's DESKTOP directory to the specified directory (must be absolute): diff --git a/tldr/uv-help b/tldr/uv-help new file mode 100644 index 00000000..0d2104dc --- /dev/null +++ b/tldr/uv-help @@ -0,0 +1,25 @@ +--- +syntax: markdown +tags: [tldr, common] +source: https://github.com/tldr-pages/tldr.git +--- +# uv help + +> Display detailed documentation for `uv` commands. +> More information: . + +- Display general help for `uv`: + +`uv help` + +- Display help for a specific command: + +`uv help {{command}}` + +- Display help for a subcommand: + +`uv help {{command}} {{subcommand}}` + +- Display help without using a pager: + +`uv help --no-pager {{command}}` diff --git a/tldr/uv-lock b/tldr/uv-lock new file mode 100644 index 00000000..38ea920e --- /dev/null +++ b/tldr/uv-lock @@ -0,0 +1,37 @@ +--- +syntax: markdown +tags: [tldr, common] +source: https://github.com/tldr-pages/tldr.git +--- +# uv lock + +> Update the project's lockfile. +> More information: . + +- Create or update the project's lockfile: + +`uv lock` + +- Check if the lockfile is up-to-date without updating it: + +`uv lock --check` + +- Assert that a lockfile exists without checking if it's current: + +`uv lock --check-exists` + +- Preview what would be locked without writing the lockfile: + +`uv lock --dry-run` + +- Lock a specific Python script instead of the current project: + +`uv lock --script {{path/to/script.py}}` + +- Upgrade all packages to their latest compatible versions: + +`uv lock --upgrade` + +- Upgrade only specific packages: + +`uv lock --upgrade-package {{package1}} --upgrade-package {{package2}}` diff --git a/tldr/uv-pip b/tldr/uv-pip new file mode 100644 index 00000000..f30c41bb --- /dev/null +++ b/tldr/uv-pip @@ -0,0 +1,41 @@ +--- +syntax: markdown +tags: [tldr, common] +source: https://github.com/tldr-pages/tldr.git +--- +# uv pip + +> Provides pip-like commands for installing, uninstalling, and managing packages. +> More information: . + +- Install a package: + +`uv pip install {{package}}` + +- Install packages from a requirements file: + +`uv pip install {{[-r|--requirements]}} {{requirements.txt}}` + +- Install a package with a specific version: + +`uv pip install {{package==1.2.3}}` + +- Uninstall a package: + +`uv pip uninstall {{package}}` + +- Save installed packages to file: + +`uv pip freeze > {{requirements.txt}}` + +- List installed packages: + +`uv pip list` + +- Show information about an installed package: + +`uv pip show {{package}}` + +- Sync environment with a requirements file (install/uninstall to match exactly): + +`uv pip sync {{requirements.txt}}` diff --git a/tldr/uv-remove b/tldr/uv-remove new file mode 100644 index 00000000..ab814e9c --- /dev/null +++ b/tldr/uv-remove @@ -0,0 +1,33 @@ +--- +syntax: markdown +tags: [tldr, common] +source: https://github.com/tldr-pages/tldr.git +--- +# uv remove + +> Remove dependencies from the project's `pyproject.toml` file. +> More information: . + +- Remove a dependency from the project: + +`uv remove {{package}}` + +- Remove multiple dependencies: + +`uv remove {{package1}} {{package2}}` + +- Remove a development dependency: + +`uv remove --dev {{package}}` + +- Remove a dependency from an optional dependency group: + +`uv remove --optional {{extra_name}} {{package}}` + +- Remove a dependency from a specific dependency group: + +`uv remove --group {{group_name}} {{package}}` + +- Remove without syncing the virtual environment: + +`uv remove --no-sync {{package}}` diff --git a/tldr/uv-run b/tldr/uv-run new file mode 100644 index 00000000..a79fd796 --- /dev/null +++ b/tldr/uv-run @@ -0,0 +1,33 @@ +--- +syntax: markdown +tags: [tldr, common] +source: https://github.com/tldr-pages/tldr.git +--- +# uv run + +> Run a command or script in the project environment. +> More information: . + +- Run a Python script: + +`uv run {{script.py}}` + +- Run a Python module: + +`uv run {{[-m|--module]}} {{module_name}}` + +- Run a command with additional packages installed temporarily: + +`uv run --with {{package}} {{command}}` + +- Run a script with packages from a requirements file: + +`uv run --with-requirements {{requirements.txt}} {{script.py}}` + +- Run in an isolated environment (no project dependencies): + +`uv run --isolated {{script.py}}` + +- Run without syncing the environment first: + +`uv run --no-sync {{command}}` diff --git a/tldr/uv-sync b/tldr/uv-sync new file mode 100644 index 00000000..ab7e50b0 --- /dev/null +++ b/tldr/uv-sync @@ -0,0 +1,41 @@ +--- +syntax: markdown +tags: [tldr, common] +source: https://github.com/tldr-pages/tldr.git +--- +# uv sync + +> Update the project's environment to match the lockfile. +> More information: . + +- Sync the project environment with the lockfile: + +`uv sync` + +- Sync and include all optional dependencies: + +`uv sync --all-extras` + +- Sync with specific optional dependencies: + +`uv sync --extra {{extra_name}}` + +- Sync only development dependencies: + +`uv sync --only-dev` + +- Sync excluding development dependencies: + +`uv sync --no-dev` + +- Sync specific dependency groups: + +`uv sync --group {{group_name}}` + +- Check if environment is already synchronized (no changes): + +`uv sync --check` + +- Preview what would be synced without making changes: + +`uv sync --dry-run` diff --git a/tldr/uv-venv b/tldr/uv-venv new file mode 100644 index 00000000..3be0bfef --- /dev/null +++ b/tldr/uv-venv @@ -0,0 +1,29 @@ +--- +syntax: markdown +tags: [tldr, common] +source: https://github.com/tldr-pages/tldr.git +--- +# uv venv + +> Create an isolated Python environment for installing packages. +> More information: . + +- Create a virtual environment in the default location (`.venv`): + +`uv venv` + +- Create a virtual environment at a specific path: + +`uv venv {{path/to/venv}}` + +- Create using a specific Python version: + +`uv venv --python {{3.12}}` + +- Create with a custom prompt prefix: + +`uv venv --prompt {{my_project}}` + +- Create and allow overwriting existing environment: + +`uv venv --allow-existing {{venv_name}}` diff --git a/tldr/uv-version b/tldr/uv-version new file mode 100644 index 00000000..7227b8a7 --- /dev/null +++ b/tldr/uv-version @@ -0,0 +1,33 @@ +--- +syntax: markdown +tags: [tldr, common] +source: https://github.com/tldr-pages/tldr.git +--- +# uv version + +> Read or update a project's version. +> More information: . + +- Display the current project version: + +`uv version` + +- Set the project version to a specific value: + +`uv version {{1.2.3}}` + +- Bump the project version using semantic versioning: + +`uv version --bump {{major|minor|patch}}` + +- Preview version changes without writing to `pyproject.toml`: + +`uv version --bump {{patch}} --dry-run` + +- Update version for a specific package in a workspace: + +`uv version --package {{package_name}} {{1.2.3}}` + +- Display version in JSON format: + +`uv version --output-format json`