From 475dea095fde66c57a276660b2e6693f75caaf1c Mon Sep 17 00:00:00 2001 From: work Date: Thu, 7 Dec 2023 05:11:26 +0300 Subject: [PATCH] doc : update bash. --- .config/bash/module/android.sh | 2 +- .config/bash/module/archive.sh | 2 +- .config/bash/module/checksum.sh | 4 +- .config/bash/module/copypaste.sh | 4 +- .config/bash/module/dconf.sh | 4 +- .config/bash/module/ffmpeg.sh | 2 +- .config/bash/module/ls.sh | 2 +- .config/bash/module/name.sh | 2 +- .config/bash/module/tmux.sh | 4 +- .config/bash/module/todo.sh | 2 +- .config/bash/module/toolbx.sh | 6 +- .doc/bash.md | 250 +++++++++++++++++++++++++++++-- 12 files changed, 251 insertions(+), 33 deletions(-) diff --git a/.config/bash/module/android.sh b/.config/bash/module/android.sh index c41e80e..bff9202 100644 --- a/.config/bash/module/android.sh +++ b/.config/bash/module/android.sh @@ -1,5 +1,5 @@ # Start an Android emulator. -# Default name is "default". +# Default name is `default`. # Usage: emulator [NAME] function emulator() { local name="${1}" diff --git a/.config/bash/module/archive.sh b/.config/bash/module/archive.sh index 38a79a7..51c2af0 100644 --- a/.config/bash/module/archive.sh +++ b/.config/bash/module/archive.sh @@ -325,7 +325,7 @@ function archive_name() { fi } -# Convert old archives to a new format. TODO: remove me after some time when there won't be any old archives. +# Convert old archives to a new format. *TODO: remove me after some time when there won't be any old archives.* function archive_convert() { local IFS=$'\n' local old_format="_[[:alnum:]]{40}.tar.[xg]z" diff --git a/.config/bash/module/checksum.sh b/.config/bash/module/checksum.sh index fd07803..8be9bfb 100644 --- a/.config/bash/module/checksum.sh +++ b/.config/bash/module/checksum.sh @@ -1,5 +1,5 @@ # Save file checksums. -# For file with a name "file" it will create a new file called ".file.sha1" with hash in it. +# For file with a name `file` it will create a new file called `.file.sha1` with hash in it. # All files by default. # Usage: checksum_create [FILES] function checksum_create() { @@ -99,7 +99,7 @@ function checksum_check() { fi } -# Calculate hashes for all files recursively and store in a file called "checksum.sha1". +# Calculate hashes for all files recursively and store in a file called `checksum.sha1`. function checksum() { find -type f | parallel -j $(_core_count) -- sha1sum {} >> checksum.sha1 } diff --git a/.config/bash/module/copypaste.sh b/.config/bash/module/copypaste.sh index 09d03b5..db691cf 100644 --- a/.config/bash/module/copypaste.sh +++ b/.config/bash/module/copypaste.sh @@ -1,9 +1,9 @@ -# Copy stdin to system clipboard. Example: echo hi | copy +# Copy stdin to system clipboard. *Example:* `echo hi \| copy`. function copy() { wl-copy } -# Paste system clipboard to stdout. Example: paste > file.txt +# Paste system clipboard to stdout. *Example:* `paste > file.txt`. function paste() { wl-paste } diff --git a/.config/bash/module/dconf.sh b/.config/bash/module/dconf.sh index 0e7ffc9..da4e846 100644 --- a/.config/bash/module/dconf.sh +++ b/.config/bash/module/dconf.sh @@ -6,8 +6,8 @@ function dconf_load() { } # Dump Gnome settings into the file. -# Default name is gnome.dconf. -# Do this before changing settings and after, an then run diff to find out what to add to main gnome.dconf. +# Default name is `gnome.dconf`. +# Do this before changing settings and after, an then run `diff` to find out what to add to the main `gnome.dconf`. # Usage: dconf_save [FILE] function dconf_save() { local name="${1}" diff --git a/.config/bash/module/ffmpeg.sh b/.config/bash/module/ffmpeg.sh index 2c75cf1..ee6bba0 100644 --- a/.config/bash/module/ffmpeg.sh +++ b/.config/bash/module/ffmpeg.sh @@ -1,4 +1,4 @@ -# Mux audio into containers. File names in sound and current dirrectories must match. Tmp usage for anime downloads. +# Mux audio into containers. File names in sound and current dirrectories must match. # Usage: ffmpeg_mux_audio function ffmpeg_mux_audio() { if [[ "${1}" = "" ]]; then diff --git a/.config/bash/module/ls.sh b/.config/bash/module/ls.sh index cd68cb9..6013d1d 100644 --- a/.config/bash/module/ls.sh +++ b/.config/bash/module/ls.sh @@ -18,7 +18,7 @@ function ll() { # List files in tree structure. # Current dir by default. -# Depth can be omitted by passing - (dash). +# Depth can be omitted by passing `-` (dash). # Usage: lll [DEPTH] [DIRS] function lll() { local IFS=$'\n' diff --git a/.config/bash/module/name.sh b/.config/bash/module/name.sh index 6af399a..8f2226a 100644 --- a/.config/bash/module/name.sh +++ b/.config/bash/module/name.sh @@ -167,7 +167,7 @@ function name_hash_check() { fi } -# Rename files for Jellyfin series, i.e. Episode S01E01.mkv +# Rename files for Jellyfin series, i.e. `Episode S01E01.mkv` # All files by default. # Usage: name_series [FILES] function name_series() { diff --git a/.config/bash/module/tmux.sh b/.config/bash/module/tmux.sh index f23af17..b56b304 100644 --- a/.config/bash/module/tmux.sh +++ b/.config/bash/module/tmux.sh @@ -1,5 +1,5 @@ # Create/attach to named session. -# By default uses name "main". +# By default uses name `main`. # Usage: ta [NAME] function ta() { local name="$1" @@ -44,7 +44,7 @@ function tn() { } # Kill specified session. -# By default it kills "main" session. +# By default it kills `main` session. # Usage: tk [NAME] function tk() { # set default name. diff --git a/.config/bash/module/todo.sh b/.config/bash/module/todo.sh index e14e4f5..e973693 100644 --- a/.config/bash/module/todo.sh +++ b/.config/bash/module/todo.sh @@ -1,4 +1,4 @@ -# Open ~/.todo.md file. +# Open `~/.todo.md` file. function todo() { vi ~/.todo.md } diff --git a/.config/bash/module/toolbx.sh b/.config/bash/module/toolbx.sh index c1546be..e67626f 100644 --- a/.config/bash/module/toolbx.sh +++ b/.config/bash/module/toolbx.sh @@ -1,5 +1,5 @@ # Attach/create toolbx container with specified name. -# By default uses "main" name. +# By default uses `main` name. # Usage: tba [NAME] function tba() { local name="${1}" @@ -38,7 +38,7 @@ function tba() { } # Remove toolbx container with specified name. -# By default uses "main" name. +# By default uses `main` name. # Usage: tbk [NAME] function tbk() { local name="${1}" @@ -53,7 +53,7 @@ function tbk() { } # Install rpm-fusion repository into container with specified name. -# By default uses "main" name. +# By default uses `main` name. # Usage: tb_rpmfusion [NAME] function tb_rpmfusion() { local name="${1}" diff --git a/.doc/bash.md b/.doc/bash.md index 46fab79..bce4480 100644 --- a/.doc/bash.md +++ b/.doc/bash.md @@ -10,40 +10,107 @@ or $ h ``` +## Android. + +Command|Description +---|--- +emulator [NAME]|Start an Android emulator. Default name is `default`. + +## Archive. + Command|Description ---|--- -emulator [NAME]|Start an Android emulator. Default name is "default". archive [DIRS]|Archive directories. All directories by default. archive_fast [DIRS]|Archive directories with fast compression. All directories by default. archive_check [FILES]|Check archives integrity. Checks all archives by default. archive_prune [NAME]|Delete old versions of archives. All archives by default. unarchive [FILES]|Extract previously created archive with checksum validation. archive_name [ARCHIVE] [NAME]|Rename archives. If no name specified, it simplifies archive's name. If no archives specified, apply to all archives. -archive_convert|Convert old archives to a new format. TODO: remove me after some time when there won't be any old archives. +archive_convert|Convert old archives to a new format. *TODO: remove me after some time when there won't be any old archives.* + +## Battery. + +Command|Description +---|--- battery_level|Print current battery level. + +## Bootstrap. + +Command|Description +---|--- bootstrap_rust|Install Cargo/Rust. bootstrap_texlive|Install TeXLive. bootstrap_grub|Install grub theme. bootstrap_ffmpeg|Install ffmpeg. + +## Cd. + +Command|Description +---|--- cdd |CD (back) to directory. Finds first directory that matches the input (case-insensitive). -checksum_create [FILES]|Save file checksums. For file with a name "file" it will create a new file called ".file.sha1" with hash in it. All files by default. + +## Checksum. + +Command|Description +---|--- +checksum_create [FILES]|Save file checksums. For file with a name `file` it will create a new file called `.file.sha1` with hash in it. All files by default. checksum_check [FILES]|Check stored values against actual files. All files by default. -checksum|Calculate hashes for all files recursively and store in a file called "checksum.sha1". +checksum|Calculate hashes for all files recursively and store in a file called `checksum.sha1`. + +## Chmod. + +Command|Description +---|--- x |Add executable flag to file. + +## Color. + +Command|Description +---|--- color_test|Print all available colors with their names colored in corresponding color. -copy|Copy stdin to system clipboard. Example: echo hi | copy -paste|Paste system clipboard to stdout. Example: paste > file.txt + +## Copypaste. + +Command|Description +---|--- +copy|Copy stdin to system clipboard. *Example:* `echo hi \| copy`. +paste|Paste system clipboard to stdout. *Example:* `paste > file.txt`. + +## Cp. + +Command|Description +---|--- cp |Replaces default cp with rsync. cp_merge |Copy and also merge all changes (delete dst files that do not exist in src). cp_link |Copy by creating hardlinks. Works for directories, too. bcp|Default cp, a.k.a builtin cp. When you don't need rsync. cp_test |Print output of cp_merge without writing anything. + +## Date. + +Command|Description +---|--- today|Print today date in yyyyMMdd format. dow|Current day of week number. + +## Dconf. + +Command|Description +---|--- dconf_load|Load Gnome settings. -dconf_save [FILE]|Dump Gnome settings into the file. Default name is gnome.dconf. Do this before changing settings and after, an then run diff to find out what to add to main gnome.dconf. +dconf_save [FILE]|Dump Gnome settings into the file. Default name is `gnome.dconf`. Do this before changing settings and after, an then run `diff` to find out what to add to the main `gnome.dconf`. + +## Disk. + +Command|Description +---|--- df|Show only physical drives info. du [DIRS]|Show combined size in SI. Current dir by default. + +## Docker. + +Command|Description +---|--- docker_volumes |Show container's volumes. docker_health|Check if any container exited. docker_ip |Find out container's IP address. @@ -59,16 +126,46 @@ dcs [SERVICES]|Docker compose stop. dcdu [SERVICES]|Docker compose down & up specified services. dcpu [SERVICES]|Docker compose pull & up specified services. dcul [SERVICES]|Docker compose up & attach to logs for specified services. + +## Doc. + +Command|Description +---|--- doc_bash|Generate a markdown file with all the help info. Outputs to `~/.doc/bash.md`. -ffmpeg_mux_audio |Mux audio into containers. File names in sound and current dirrectories must match. Tmp usage for anime downloads. + +## Ffmpeg. + +Command|Description +---|--- +ffmpeg_mux_audio |Mux audio into containers. File names in sound and current dirrectories must match. ffmpeg_mux_cover |Mux cover into music file. ffmpeg_music_meta |Generate music metadata from directory structure. Top dir is the Artist name like this: `The_Beatles`. Next are albums like this: `2010_My_love`. Inside are songs like this: `01_sample.flac`. + +## File. + +Command|Description +---|--- o |Open file/dir in GUI. + +## Find. + +Command|Description +---|--- find_ext|Find all file extensions. find_module|Find all modules. find_function [MODULE]|Find all module functions. Functions from all modules by default. + +## Fix. + +Command|Description +---|--- fix_ethernet_speed |Fix when ethernet mistakenly detects 100 Mb instead of 1000 Mb. SPEED is one of 10/100/1000 etc. fix_files_sftp|Fix nautilus after typing wrong sftp password. + +## Git. + +Command|Description +---|--- gps|Git push. gpsf|Git force push. gpl|Git pull. @@ -93,59 +190,180 @@ gr [COMMIT COUNT]|Rebase by X commits or from root. When COUNT is 0 - rebase fro gu [EMAIL]|Specify git user as Dmitry Voronin with provided email. gg |Get my git repo. gdc |See diff for a specific commit. + +## Help. + +Command|Description +---|--- help |Get help about dotfiles bash function. h |Short for help. + +## Ls. + +Command|Description +---|--- l [DIRS]|List files in dirs. Current dir by default. ll [DIRS]|List last modified files first. Current dir by default. -lll [DEPTH] [DIRS]|List files in tree structure. Current dir by default. Depth can be omitted by passing - (dash). +lll [DEPTH] [DIRS]|List files in tree structure. Current dir by default. Depth can be omitted by passing `-` (dash). llll [DIRS]|List files recursively. Current dir by default. la [DIRS]|List all files in dirs, incl. hidden files. Current dir by default. lla [DIRS]|List all files in dirs, incl. hidden files, sorted by mtime. Current dir by default. + +## Name. + +Command|Description +---|--- name [FILES]|Rename files to strip all special characters. All files by default. name_hash [FILES]|Rename all files to their hashes while keeping extensions. All files by default. name_hash_check [FILES]|Check hashes for previously renamed files. All files by default. -name_series [FILES]|Rename files for Jellyfin series, i.e. Episode S01E01.mkv All files by default. +name_series [FILES]|Rename files for Jellyfin series, i.e. `Episode S01E01.mkv` All files by default. name_manga [FILES]|Rename files for Kavita manga format. All files by default. name_ext [FILES]|Rename files with new extension. All files by default. name_prefix [FILES]|Change file name prefix. All matching files by default. name_postfix [FILES]|Change file name postfix. All matching files by default. name_replace [FILES]|Replace part of the name. All matching files by default. + +## Ncdu. + +Command|Description +---|--- ncdu [DIRS]|Search only on current filesystem. Current dir by default. + +## Notify. + +Command|Description +---|--- notify |Send Telegram notification. notify_silent |Send silent Telegram notification. + +## Own. + +Command|Description +---|--- own [USER] [FILES]|Change file ownership to specified user id and restrict access to him. Root user by default. This directory recursively by default. + +## Pack. + +Command|Description +---|--- pack [FILES]|Pack files into desired format. All files and directories by default. unpack [FILES]|Attempt to unpack. All supported formats by default. + +## Parse. + +Command|Description +---|--- parse_simplify |Parse data and output simplified format. parse_camel |Parse to CamelCase. parse_alnum |Parse data keeping only alphanumeric characters. + +## Permissions. + +Command|Description +---|--- perm_share|Recursively change permissions to allow read sharing with group and others. perm|Recursively change permissions to restrict access for group and others. + +## Ps. + +Command|Description +---|--- ps |Find process and filter. + +## Recursive. + +Command|Description +---|--- recursive |Run something recursively over all directories. recursive1 |Run something recursively over directories of 1 depth (excluding current dir). + +## Rust. + +Command|Description +---|--- rust_book|Open Rust book. + +## Su. + +Command|Description +---|--- s [USER]|Su shortcut for lazy me. Root by default. + +## Terminal. + +Command|Description +---|--- tsize|Get terminal size. + +## Tmp. + +Command|Description +---|--- tmp|CD into host's primary tmp dir. -ta [NAME]|Create/attach to named session. By default uses name "main". + +## Tmux. + +Command|Description +---|--- +ta [NAME]|Create/attach to named session. By default uses name `main`. td|Detach from running session. tl|List running sessions. trn [NAME]|Rename current session. Uses current dir name by default. tn [NAME]|Assign name to window. Uses current dir name by default. -tk [NAME]|Kill specified session. By default it kills "main" session. +tk [NAME]|Kill specified session. By default it kills `main` session. tka|Kill all sessions. -todo|Open ~/.todo.md file. -tba [NAME]|Attach/create toolbx container with specified name. By default uses "main" name. -tbk [NAME]|Remove toolbx container with specified name. By default uses "main" name. -tb_rpmfusion [NAME]|Install rpm-fusion repository into container with specified name. By default uses "main" name. + +## Todo. + +Command|Description +---|--- +todo|Open `~/.todo.md` file. + +## Toolbx. + +Command|Description +---|--- +tba [NAME]|Attach/create toolbx container with specified name. By default uses `main` name. +tbk [NAME]|Remove toolbx container with specified name. By default uses `main` name. +tb_rpmfusion [NAME]|Install rpm-fusion repository into container with specified name. By default uses `main` name. tbl|List all available containers. + +## Transcode. + +Command|Description +---|--- transcode [FILES]|Convert between different formats. By default tries to convert all files. + +## Try. + +Command|Description +---|--- try |Retry command every 2 sec until it completes successfully. + +## Vdl. + +Command|Description +---|--- vdl [LINK]|Download video from URL. When no [LINK] specified, it tries to update previously downloaded link. vdl_vk |Temporary fix for vk downloads. vdl_file |Download all videos from file with links. + +## Vi. + +Command|Description +---|--- v|Neovim shortcut. + +## Wallpaper. + +Command|Description +---|--- wallpaper |Set specified file as a wallpaper. + +## Watch. + +Command|Description +---|--- w |Watch command output with 2 seconds interval. ww |Watch command output with minimal interval. +