From 273f2b186d94f5198bb67b65587355402d720650 Mon Sep 17 00:00:00 2001 From: ivuorinen Date: Fri, 27 Dec 2024 00:17:30 +0000 Subject: [PATCH] Update cheatsheets --- tldr/% | 33 +++++++++++++++++++++++++++++++ tldr/adb | 4 ++++ tldr/adb-forward | 25 +++++++++++++++++++++++ tldr/compgen | 4 ++++ tldr/continue | 17 ++++++++++++++++ tldr/declare | 6 +++++- tldr/for | 4 ++++ tldr/getopts | 30 ++++++++++++++++++++++++++++ tldr/greater-than | 4 ++-- tldr/hash | 25 +++++++++++++++++++++++ tldr/home-manager | 20 +++++++++++++++---- tldr/latexpand | 29 +++++++++++++++++++++++++++ tldr/linux/bootc-switch | 21 ++++++++++++++++++++ tldr/linux/insmod | 2 +- tldr/linux/pacman-d | 12 +++++++++++ tldr/linux/pacman-database | 18 ++++++++--------- tldr/linux/pacman-de | 12 +++++++++++ tldr/linux/pacman-deptest | 10 +++++----- tldr/linux/pacman-u | 12 +++++++++++ tldr/linux/pacman-upgrade | 16 +++++++-------- tldr/linux/steamos-session-select | 10 +++++++--- tldr/logout | 17 ++++++++++++++++ tldr/mapfile | 12 +++++++++++ tldr/osx/darwin-rebuild | 21 ++++++++++++++++++++ tldr/pangolin | 17 ++++++++++++++++ tldr/return | 17 ++++++++++++++++ tldr/suspend | 21 ++++++++++++++++++++ tldr/times | 13 ++++++++++++ tldr/while | 4 ++-- 29 files changed, 401 insertions(+), 35 deletions(-) create mode 100644 tldr/% create mode 100644 tldr/adb-forward create mode 100644 tldr/continue create mode 100644 tldr/getopts create mode 100644 tldr/hash create mode 100644 tldr/latexpand create mode 100644 tldr/linux/bootc-switch create mode 100644 tldr/linux/pacman-d create mode 100644 tldr/linux/pacman-de create mode 100644 tldr/linux/pacman-u create mode 100644 tldr/logout create mode 100644 tldr/mapfile create mode 100644 tldr/osx/darwin-rebuild create mode 100644 tldr/pangolin create mode 100644 tldr/return create mode 100644 tldr/suspend create mode 100644 tldr/times diff --git a/tldr/% b/tldr/% new file mode 100644 index 00000000..92f718c6 --- /dev/null +++ b/tldr/% @@ -0,0 +1,33 @@ +--- +syntax: markdown +tags: [tldr, common] +source: https://github.com/tldr-pages/tldr.git +--- +# Percent sign + +> Manage jobs. +> More information: . + +- 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}} &` diff --git a/tldr/adb b/tldr/adb index 44432609..211504f4 100644 --- a/tldr/adb +++ b/tldr/adb @@ -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}}` diff --git a/tldr/adb-forward b/tldr/adb-forward new file mode 100644 index 00000000..5ac9c49b --- /dev/null +++ b/tldr/adb-forward @@ -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: . + +- 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` diff --git a/tldr/compgen b/tldr/compgen index 98ac80dc..9dabfb41 100644 --- a/tldr/compgen +++ b/tldr/compgen @@ -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` diff --git a/tldr/continue b/tldr/continue new file mode 100644 index 00000000..db4087d3 --- /dev/null +++ b/tldr/continue @@ -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: . + +- 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` diff --git a/tldr/declare b/tldr/declare index 6bc180af..708b55dc 100644 --- a/tldr/declare +++ b/tldr/declare @@ -6,7 +6,7 @@ source: https://github.com/tldr-pages/tldr.git # declare > Declare variables and give them attributes. -> More information: . +> More information: . - 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}}` diff --git a/tldr/for b/tldr/for index 15b56418..8b6e69f7 100644 --- a/tldr/for +++ b/tldr/for @@ -8,6 +8,10 @@ source: https://github.com/tldr-pages/tldr.git > Perform a command several times. > More information: . +- 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` diff --git a/tldr/getopts b/tldr/getopts new file mode 100644 index 00000000..758738f8 --- /dev/null +++ b/tldr/getopts @@ -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: . + +- 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` diff --git a/tldr/greater-than b/tldr/greater-than index 476b6b05..3fd29069 100644 --- a/tldr/greater-than +++ b/tldr/greater-than @@ -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: diff --git a/tldr/hash b/tldr/hash new file mode 100644 index 00000000..758eaeaf --- /dev/null +++ b/tldr/hash @@ -0,0 +1,25 @@ +--- +syntax: markdown +tags: [tldr, common] +source: https://github.com/tldr-pages/tldr.git +--- +# hash + +> View cached executable locations. +> More information: . + +- 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}}` diff --git a/tldr/home-manager b/tldr/home-manager index 195bc761..10fbbfbf 100644 --- a/tldr/home-manager +++ b/tldr/home-manager @@ -5,13 +5,25 @@ source: https://github.com/tldr-pages/tldr.git --- # home-manager -> Manage a user environment using Nix. -> More information: . +> Manage a per-user environment using Nix, allowing declarative configuration of the user’s home. +> More information: . -- 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` diff --git a/tldr/latexpand b/tldr/latexpand new file mode 100644 index 00000000..17b26913 --- /dev/null +++ b/tldr/latexpand @@ -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: . + +- 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}}` diff --git a/tldr/linux/bootc-switch b/tldr/linux/bootc-switch new file mode 100644 index 00000000..51f3c41d --- /dev/null +++ b/tldr/linux/bootc-switch @@ -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: . + +- 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}}` diff --git a/tldr/linux/insmod b/tldr/linux/insmod index 0d5bc592..8b6f496e 100644 --- a/tldr/linux/insmod +++ b/tldr/linux/insmod @@ -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}}` diff --git a/tldr/linux/pacman-d b/tldr/linux/pacman-d new file mode 100644 index 00000000..bf8b66c4 --- /dev/null +++ b/tldr/linux/pacman-d @@ -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` diff --git a/tldr/linux/pacman-database b/tldr/linux/pacman-database index 46ec683d..1b190e7c 100644 --- a/tldr/linux/pacman-database +++ b/tldr/linux/pacman-database @@ -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` diff --git a/tldr/linux/pacman-de b/tldr/linux/pacman-de new file mode 100644 index 00000000..99a083c5 --- /dev/null +++ b/tldr/linux/pacman-de @@ -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` diff --git a/tldr/linux/pacman-deptest b/tldr/linux/pacman-deptest index 568d452d..33fb5a32 100644 --- a/tldr/linux/pacman-deptest +++ b/tldr/linux/pacman-deptest @@ -9,18 +9,18 @@ source: https://github.com/tldr-pages/tldr.git > See also: `pacman`. > More information: . -- 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` diff --git a/tldr/linux/pacman-u b/tldr/linux/pacman-u new file mode 100644 index 00000000..775e277b --- /dev/null +++ b/tldr/linux/pacman-u @@ -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` diff --git a/tldr/linux/pacman-upgrade b/tldr/linux/pacman-upgrade index 7f38ed82..9889b4ef 100644 --- a/tldr/linux/pacman-upgrade +++ b/tldr/linux/pacman-upgrade @@ -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` diff --git a/tldr/linux/steamos-session-select b/tldr/linux/steamos-session-select index d4a6533e..3dc4bb37 100644 --- a/tldr/linux/steamos-session-select +++ b/tldr/linux/steamos-session-select @@ -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` diff --git a/tldr/logout b/tldr/logout new file mode 100644 index 00000000..88c32100 --- /dev/null +++ b/tldr/logout @@ -0,0 +1,17 @@ +--- +syntax: markdown +tags: [tldr, common] +source: https://github.com/tldr-pages/tldr.git +--- +# logout + +> Exit a login shell. +> More information: . + +- Exit a login shell: + +`logout` + +- Exit a login shell and specify a return value: + +`logout {{N}}` diff --git a/tldr/mapfile b/tldr/mapfile new file mode 100644 index 00000000..f17b6360 --- /dev/null +++ b/tldr/mapfile @@ -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` diff --git a/tldr/osx/darwin-rebuild b/tldr/osx/darwin-rebuild new file mode 100644 index 00000000..7201acca --- /dev/null +++ b/tldr/osx/darwin-rebuild @@ -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: . + +- 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` diff --git a/tldr/pangolin b/tldr/pangolin new file mode 100644 index 00000000..1505f96f --- /dev/null +++ b/tldr/pangolin @@ -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: . + +- Run `pangolin` on the specified FASTA file: + +`pangolin {{path/to/file.fa}}` + +- Use the specified analysis engine: + +`pangolin --analysis-mode {{accurate|fast|pangolearn|usher}}` diff --git a/tldr/return b/tldr/return new file mode 100644 index 00000000..9147d7a6 --- /dev/null +++ b/tldr/return @@ -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: . + +- 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}}; }` diff --git a/tldr/suspend b/tldr/suspend new file mode 100644 index 00000000..2f034471 --- /dev/null +++ b/tldr/suspend @@ -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: . + +- Suspend the current shell (useful for when you are in nested shells like `su`): + +`{{bash}} 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` diff --git a/tldr/times b/tldr/times new file mode 100644 index 00000000..b16279a0 --- /dev/null +++ b/tldr/times @@ -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: . + +- Print CPU usage. First line is current shell CPU usage for User and System. Second is all child processes: + +`times` diff --git a/tldr/while b/tldr/while index c083034b..f021af94 100644 --- a/tldr/while +++ b/tldr/while @@ -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: . - 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`