Update cheatsheets

This commit is contained in:
ivuorinen
2025-06-19 00:20:52 +00:00
parent 0d1118b990
commit a746c9d8f6
15 changed files with 391 additions and 13 deletions

42
tldr/dropdb Normal file
View File

@@ -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: <https://www.postgresql.org/docs/current/app-dropdb.html>.
- 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}}`

View File

@@ -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):

41
tldr/komac Normal file
View File

@@ -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: <https://github.com/russellbanks/Komac>.
- 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}}`

View File

@@ -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:

View File

@@ -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: <https://www.gnu.org/software/sed/manual/sed.html>.
- 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}}`

18
tldr/linux/xdg-user-dir Normal file
View File

@@ -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: <https://manned.org/xdg-user-dir>.
- 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}}`

View File

@@ -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: <https://manned.org/xdg-user-dirs-update>.
- Change XDG's DESKTOP directory to the specified directory (must be absolute):

25
tldr/uv-help Normal file
View File

@@ -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: <https://docs.astral.sh/uv/reference/cli/#uv-help>.
- 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}}`

37
tldr/uv-lock Normal file
View File

@@ -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: <https://docs.astral.sh/uv/reference/cli/#uv-lock>.
- 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}}`

41
tldr/uv-pip Normal file
View File

@@ -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: <https://docs.astral.sh/uv/reference/cli/#uv-pip>.
- 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}}`

33
tldr/uv-remove Normal file
View File

@@ -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: <https://docs.astral.sh/uv/reference/cli/#uv-remove>.
- 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}}`

33
tldr/uv-run Normal file
View File

@@ -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: <https://docs.astral.sh/uv/reference/cli/#uv-run>.
- 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}}`

41
tldr/uv-sync Normal file
View File

@@ -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: <https://docs.astral.sh/uv/reference/cli/#uv-sync>.
- 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`

29
tldr/uv-venv Normal file
View File

@@ -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: <https://docs.astral.sh/uv/reference/cli/#uv-venv>.
- 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}}`

33
tldr/uv-version Normal file
View File

@@ -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: <https://docs.astral.sh/uv/reference/cli/#uv-version>.
- 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`