Update cheatsheets

This commit is contained in:
ivuorinen
2024-12-27 00:17:30 +00:00
parent dfbc0264f9
commit 273f2b186d
29 changed files with 401 additions and 35 deletions

33
tldr/% Normal file
View File

@@ -0,0 +1,33 @@
---
syntax: markdown
tags: [tldr, common]
source: https://github.com/tldr-pages/tldr.git
---
# Percent sign
> Manage jobs.
> More information: <https://www.gnu.org/software/bash/manual/bash.html#Job-Control-Basics>.
- Bring the current job to front:
`%`
- Bring the previous job to front:
`%-`
- Bring a job numbered `N` to front:
`%{{N}}`
- Bring a job whose command starts with `string` to front:
`%{{string}}`
- Bring a job whose command contains `string` to front:
`%?{{string}}`
- Resume a suspended job:
`%{{1}} &`

View File

@@ -36,3 +36,7 @@ source: https://github.com/tldr-pages/tldr.git
- List all connected devices:
`adb devices`
- Specify which device to send commands to if there are multiple devices:
`adb -s {{device_ID}} {{shell}}`

25
tldr/adb-forward Normal file
View File

@@ -0,0 +1,25 @@
---
syntax: markdown
tags: [tldr, common]
source: https://github.com/tldr-pages/tldr.git
---
# adb forward
> Connect to an Android device wirelessly.
> More information: <https://developer.android.com/tools/adb>.
- Forward a TCP port:
`adb forward tcp:{{local_port}} tcp:{{remote_port}}`
- List all forwardings:
`adb forward --list`
- Remove a forwarding rule:
`adb forward --remove tcp:{{local_port}}`
- Remove all forwarding rules:
`adb forward --remove-all`

View File

@@ -12,6 +12,10 @@ source: https://github.com/tldr-pages/tldr.git
`compgen -c`
- List all commands that you could run that start with a specified string:
`compgen -c {{str}}`
- List all aliases:
`compgen -a`

17
tldr/continue Normal file
View File

@@ -0,0 +1,17 @@
---
syntax: markdown
tags: [tldr, common]
source: https://github.com/tldr-pages/tldr.git
---
# continue
> Skip to the next iteration of a `for`, `while`, `until` or `select` loop.
> More information: <https://www.gnu.org/software/bash/manual/bash.html#index-continue>.
- Skip to the next iteration:
`while :; do continue; echo "This will never be reached"; done`
- Skip to the next iteration from within a nested loop:
`for i in {1..3}; do while :; do continue 2; done; done`

View File

@@ -6,7 +6,7 @@ source: https://github.com/tldr-pages/tldr.git
# declare
> Declare variables and give them attributes.
> More information: <https://www.gnu.org/software/bash/manual/bash.html#Bash-Builtins>.
> More information: <https://www.gnu.org/software/bash/manual/bash.html#index-declare>.
- Declare a string variable with the specified value:
@@ -31,3 +31,7 @@ source: https://github.com/tldr-pages/tldr.git
- Declare a global variable within a function with the specified value:
`declare -g {{variable}}="{{value}}"`
- Print a function definition:
`declare -f {{function_name}}`

View File

@@ -8,6 +8,10 @@ source: https://github.com/tldr-pages/tldr.git
> Perform a command several times.
> More information: <https://www.gnu.org/software/bash/manual/bash.html#Looping-Constructs>.
- Iterate through command line arguments:
`for {{variable}}; do {{echo $variable}}; done`
- Execute the given commands for each of the specified items:
`for {{variable}} in {{item1 item2 ...}}; do {{echo "Loop is executed"}}; done`

30
tldr/getopts Normal file
View File

@@ -0,0 +1,30 @@
---
syntax: markdown
tags: [tldr, common]
source: https://github.com/tldr-pages/tldr.git
---
# getopts
> Parse shell options from arguments.
> This command does not support longform options and thus using `getopt` is recommended instead.
> More information: <https://www.gnu.org/software/bash/manual/bash.html#index-getopts>.
- Check if an option is set:
`getopts {{x}} {{opt}}; echo $opt`
- Set an option to require an argument and check said argument:
`getopts {{x}}: {{opt}}; echo $OPTARG`
- Check for multiple options:
`while getopts {{xyz}} {{opt}}; do case $opt in x) echo x is set;; y) echo y is set;; z) echo z is set;; esac; done`
- Set `getopts` to silent mode and handle option errors:
`while getopts :{{x:}} {{opt}}; do case $opt in x) ;; :) echo "Argument required";; ?) echo "Invalid argument" esac;; done`
- Reset `getopts`:
`OPTIND=1`

View File

@@ -20,9 +20,9 @@ source: https://github.com/tldr-pages/tldr.git
`{{command}} &> {{path/to/file}}`
- Redirect both `stdout` and `stderr` to `/dev/null` to keep the terminal output clean:
- Redirect `stderr` to `/dev/null` to keep the terminal output clean:
`{{command}} &> /dev/null`
`{{command}} 2> /dev/null`
- Clear the file contents or create a new empty file:

25
tldr/hash Normal file
View File

@@ -0,0 +1,25 @@
---
syntax: markdown
tags: [tldr, common]
source: https://github.com/tldr-pages/tldr.git
---
# hash
> View cached executable locations.
> More information: <https://www.gnu.org/software/bash/manual/bash.html#index-hash>.
- View cached command locations for the current shell:
`hash`
- Clear the hash table:
`hash -r`
- Delete a specific command from the hash table:
`hash -d {{command}}`
- Print the full path of `command`:
`hash -t {{command}}`

View File

@@ -5,13 +5,25 @@ source: https://github.com/tldr-pages/tldr.git
---
# home-manager
> Manage a user environment using Nix.
> More information: <https://github.com/rycee/home-manager>.
> Manage a per-user environment using Nix, allowing declarative configuration of the users home.
> More information: <https://github.com/nix-community/home-manager>.
- Activate the configuration defined in `~/.config/nixpkgs/home.nix`:
- Build the configuration defined in `~/.config/nixpkgs/home.nix` without applying it:
`home-manager build`
- Activate the configuration and switch to it:
- Build and apply (switch to) the new configuration:
`home-manager switch`
- Build the configuration for testing without applying it:
`home-manager test`
- Roll back to a previous configuration generation:
`home-manager rollback`
- List all existing configuration generations:
`home-manager generations`

29
tldr/latexpand Normal file
View File

@@ -0,0 +1,29 @@
---
syntax: markdown
tags: [tldr, common]
source: https://github.com/tldr-pages/tldr.git
---
# latexpand
> Simplify LaTeX source files by removing comments and resolving `\include`s, `\input`s, etc.
> More information: <https://www.ctan.org/pkg/latexpand>.
- Simplify the specified source file and save the result to the specified [o]utput file:
`latexpand --output {{path/to/output.tex}} {{path/to/file.tex}}`
- Do not remove comments:
`latexpand --keep-comments --output {{path/to/output.tex}} {{path/to/file.tex}}`
- Do not expand `\include`s, `\input`s etc.:
`latexpand --keep-includes --output {{path/to/output.tex}} {{path/to/file.tex}}`
- Expand `\usepackage`s as far as the corresponding STY files can be found:
`latexpand --expand-usepackage --output {{path/to/output.tex}} {{path/to/file.tex}}`
- Inline the specified BBL file:
`latexpand --expand-bbl {{path/to/bibliography.bbl}} --output {{path/to/output.tex}} {{path/to/file.tex}}`

21
tldr/linux/bootc-switch Normal file
View File

@@ -0,0 +1,21 @@
---
syntax: markdown
tags: [tldr, linux]
source: https://github.com/tldr-pages/tldr.git
---
# bootc switch
> Target a new container image reference to boot.
> More information: <https://containers.github.io/bootc/man/bootc-switch.html>.
- Change the base OS to a new container image from a registry:
`sudo bootc switch {{image}}`
- Change the base OS to a new container image from the local image storage of the root user:
`sudo bootc switch --transport containers-storage {{image}}`
- Change the base OS to a new container image stored in a tarball:
`sudo bootc switch --transport oci-archive {{path/to/image.tar.gz}}`

View File

@@ -10,4 +10,4 @@ source: https://github.com/tldr-pages/tldr.git
- Insert a kernel module into the Linux kernel:
`insmod {{path/to/module.ko}}`
`sudo insmod {{path/to/module.ko}}`

12
tldr/linux/pacman-d Normal file
View File

@@ -0,0 +1,12 @@
---
syntax: markdown
tags: [tldr, linux]
source: https://github.com/tldr-pages/tldr.git
---
# pacman -D
> This command is an alias of `pacman --database`.
- View documentation for the original command:
`tldr pacman database`

View File

@@ -12,24 +12,24 @@ source: https://github.com/tldr-pages/tldr.git
- Mark a package as implicitly installed:
`sudo pacman --database --asdeps {{package}}`
`sudo pacman -D --asdeps {{package}}`
- Mark a package as explicitly installed:
`sudo pacman --database --asexplicit {{package}}`
`sudo pacman -D --asexplicit {{package}}`
- Check that all the package dependencies are installed:
- Chec[k] that all the package dependencies are installed:
`pacman --database --check`
`pacman -Dk`
- Check the repositories to ensure all specified dependencies are available:
- Chec[k] the sync [D]atabase to ensure all specified dependencies of downloadable packages are available:
`pacman --database --check --check`
`pacman -Dkk`
- Display only error messages:
- Chec[k] and display in [q]uiet mode (only error messages are displayed):
`pacman --database --check --quiet`
`pacman -Dkq`
- Display help:
`pacman --database --help`
`pacman -D --help`

12
tldr/linux/pacman-de Normal file
View File

@@ -0,0 +1,12 @@
---
syntax: markdown
tags: [tldr, linux]
source: https://github.com/tldr-pages/tldr.git
---
# pacman -T
> This command is an alias of `pacman --deptest`.
- View documentation for the original command:
`tldr pacman deptest`

View File

@@ -9,18 +9,18 @@ source: https://github.com/tldr-pages/tldr.git
> See also: `pacman`.
> More information: <https://manned.org/pacman.8>.
- Print the package names of the dependencies that aren't installed:
- Print the package names of the dependencies that are not installed:
`pacman --deptest {{package1 package2 ...}}`
`pacman -T {{package1 package2 ...}}`
- Check if the installed package satisfies the given minimum version:
`pacman --deptest "{{bash>=5}}"`
`pacman -T "{{bash>=5}}"`
- Check if a later version of a package is installed:
`pacman --deptest "{{bash>5}}"`
`pacman -T "{{bash>5}}"`
- Display help:
`pacman --deptest --help`
`pacman -T --help`

12
tldr/linux/pacman-u Normal file
View File

@@ -0,0 +1,12 @@
---
syntax: markdown
tags: [tldr, linux]
source: https://github.com/tldr-pages/tldr.git
---
# pacman -U
> This command is an alias of `pacman --upgrade`.
- View documentation for the original command:
`tldr pacman upgrade`

View File

@@ -11,24 +11,24 @@ source: https://github.com/tldr-pages/tldr.git
- Install one or more packages from files:
`sudo pacman --upgrade {{path/to/package1.pkg.tar.zst}} {{path/to/package2.pkg.tar.zst}}`
`sudo pacman -U {{path/to/package1.pkg.tar.zst}} {{path/to/package2.pkg.tar.zst}}`
- Install a package without prompting:
`sudo pacman --upgrade --noconfirm {{path/to/package.pkg.tar.zst}}`
`sudo pacman -U --noconfirm {{path/to/package.pkg.tar.zst}}`
- Overwrite conflicting files during a package installation:
`sudo pacman --upgrade --overwrite {{path/to/file}} {{path/to/package.pkg.tar.zst}}`
`sudo pacman -U --overwrite {{path/to/file}} {{path/to/package.pkg.tar.zst}}`
- Install a package, skipping the dependency version checks:
- Install a package, skipping the dependency [(d)] version checks:
`sudo pacman --upgrade --nodeps {{path/to/package.pkg.tar.zst}}`
`sudo pacman -Ud {{path/to/package.pkg.tar.zst}}`
- List packages that would be affected (does not install any packages):
- Fetch and [p]rint packages that would be affected by upgrade (does not install any packages):
`pacman --upgrade --print {{path/to/package.pkg.tar.zst}}`
`pacman -Up {{path/to/package.pkg.tar.zst}}`
- Display help:
`pacman --upgrade --help`
`pacman -U --help`

View File

@@ -12,14 +12,18 @@ source: https://github.com/tldr-pages/tldr.git
`steamos-session-select plasma`
- Change to gamemode:
- Change to gamemode (sets the system to boot into gamemode if `-persistent` options were selected previously):
`steamos-session-select gamescope`
`steamos-session-select`
- Change to Wayland desktop mode:
`steamos-session-select plasma-wayland`
- Change to Wayland desktop mode and have the device boot to desktop:
`steamos-session-select plasma-wayland-persistent`
- Change to X11 desktop mode:
- Change to X11 desktop mode and have the device boot to desktop:
`steamos-session-select plasma-x11-persistent`

17
tldr/logout Normal file
View File

@@ -0,0 +1,17 @@
---
syntax: markdown
tags: [tldr, common]
source: https://github.com/tldr-pages/tldr.git
---
# logout
> Exit a login shell.
> More information: <https://www.gnu.org/software/bash/manual/bash.html#index-logout>.
- Exit a login shell:
`logout`
- Exit a login shell and specify a return value:
`logout {{N}}`

12
tldr/mapfile Normal file
View File

@@ -0,0 +1,12 @@
---
syntax: markdown
tags: [tldr, common]
source: https://github.com/tldr-pages/tldr.git
---
# mapfile
> This command is an alias of `readarray`.
- View documentation for the original command:
`tldr readarray`

21
tldr/osx/darwin-rebuild Normal file
View File

@@ -0,0 +1,21 @@
---
syntax: markdown
tags: [tldr, osx]
source: https://github.com/tldr-pages/tldr.git
---
# darwin-rebuild
> Rebuild and switch to a Nix-based Darwin (macOS) system configuration.
> More information: <https://github.com/LnL7/nix-darwin>.
- Rebuild and switch to the specified Darwin configuration:
`darwin-rebuild switch --flake {{path/to/flake}}`
- Build the configuration but don't switch to it:
`darwin-rebuild build --flake {{path/to/flake}}`
- Display help:
`darwin-rebuild --help`

17
tldr/pangolin Normal file
View File

@@ -0,0 +1,17 @@
---
syntax: markdown
tags: [tldr, common]
source: https://github.com/tldr-pages/tldr.git
---
# pangolin
> Implements the dynamic nomenclature of SARS-CoV-2 lineages (Pango nomenclature).
> More information: <https://cov-lineages.org/resources/pangolin/usage.html>.
- Run `pangolin` on the specified FASTA file:
`pangolin {{path/to/file.fa}}`
- Use the specified analysis engine:
`pangolin --analysis-mode {{accurate|fast|pangolearn|usher}}`

17
tldr/return Normal file
View File

@@ -0,0 +1,17 @@
---
syntax: markdown
tags: [tldr, common]
source: https://github.com/tldr-pages/tldr.git
---
# return
> Exit a function or a script if run with `source`.
> More information: <https://www.gnu.org/software/bash/manual/bash.html#index-return>.
- Exit a function prematurely:
`{{func_name}}() { {{echo "This is reached"}}; return; {{echo "This is not"}}; }`
- Specify the function's return value:
`{{func_name}}() { return {{N}}; }`

21
tldr/suspend Normal file
View File

@@ -0,0 +1,21 @@
---
syntax: markdown
tags: [tldr, common]
source: https://github.com/tldr-pages/tldr.git
---
# suspend
> Suspend the execution of the current shell.
> More information: <https://www.gnu.org/software/bash/manual/bash.html#index-suspend>.
- Suspend the current shell (useful for when you are in nested shells like `su`):
`{{bash}} <Enter> suspend`
- Run in a separate terminal to continue from suspension if `suspend` was used in a non-nested shell:
`pkill -CONT bash`
- Force suspension even if this would lock you out of the system:
`suspend -f`

13
tldr/times Normal file
View File

@@ -0,0 +1,13 @@
---
syntax: markdown
tags: [tldr, common]
source: https://github.com/tldr-pages/tldr.git
---
# times
> Print the cumulative CPU usage time of the current shell.
> More information: <https://www.gnu.org/software/bash/manual/bash.html#index-times>.
- Print CPU usage. First line is current shell CPU usage for User and System. Second is all child processes:
`times`

View File

@@ -5,7 +5,7 @@ source: https://github.com/tldr-pages/tldr.git
---
# while
> Simple shell loop.
> Simple shell loop that repeats while the return value remains zero.
> More information: <https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_04_09>.
- Read `stdin` and perform an action on every line:
@@ -16,6 +16,6 @@ source: https://github.com/tldr-pages/tldr.git
`while :; do {{command}}; sleep 1; done`
- Execute a command until it returns a non-zero value:
- Execute a command until it fails:
`while {{command}}; do :; done`