This repository has been archived on 2024-03-04. You can view files and clone it, but cannot push or open issues or pull requests.
linux/.README.md

675 lines
18 KiB
Markdown

# Custom system config.
This is my own custom config that I use on my GNU/Linux machines. Not ment to be used by anyone else.
# Table of contents.
1. [Bootstrap.](#bootstrap)
2. [General info.](#general-info)
3. [Load Gnome settings.](#load-gnome-settings)
4. [Navigation.](#navigation)
5. [Nvim config.](#nvim-config)
6. [Bash commands.](#bash-commands)
7. [To-do.](#to-do)
# Bootstrap.
**CAREFUL!** This will overwrite files with the same name in your home directory!
```bash
curl -s https://git.voronind.com/voronind/linux/raw/branch/master/.bootstrap.sh | bash && source .bashrc
```
# General info.
It includes:
1. Git config (excluding user info).
2. Bash scripts and environment.
3. Tmux config.
4. Basic directory structure as well as redefining them as default.
5. Custom bin directory.
6. Collection of Linux configs (sshd, gnome, sysctl etc).
7. GTK 3/4 configs.
8. Htop config.
9. Nvim config.
10. SSH config.
11. Custom background.
12. Flatpak overrides.
13. Custom fonts.
# Load Gnome settings.
To load Gnome settings run `dconf_load`.
# Navigation.
Navigation principles are shared between Gnome, Tmux and Nvim. The only difference is the *"Leader"* key. Gnome uses *Super* key, Tmux uses *Meta (alt)* key and Nvim uses *Space*. The rest somewhat repeats itself.
## Gnome
Key|Action
---|---
`Super+Esc`|Lauch Terminal emulator.
`Super+q`|Switch to the left workspace.
`Super+e`|Switch to the right workspace.
`Super+Q`|Move window to the left workspace.
`Super+E`|Move window to the right workspace.
`Super+\|`|None.
`Super+-`|None.
`Super+w`|Toggle window maximize.
`Super+s`|Minimize window.
`Super+a`|Snap window to the left.
`Super+d`|Snap window to the right.
`Super+z`|Lock session.
`Super+x`|Close window.
`Super+c`|Minimize all windows.
`Super+v`|Take a screenshot.
`Super+f`|Toggle window fullscreen.
## Tmux.
Key|Action
---|---
`Meta+Esc`, `Meta+t`|New window. `Meta+t` is for the Termux Android app as it can't send the `Meta+Esc` combo.
`Meta+q`|Switch to the left window.
`Meta+e`|Switch to the right window.
`Meta+Q`|Move window to the left.
`Meta+E`|Move window to the right.
`Meta+\|`|Split vertically.
`Meta+-`|Split horizontally.
`Meta+w`|Switch to the above split.
`Meta+s`|Switch to the below split.
`Meta+a`|Switch to the left split.
`Meta+d`|Switch to the right split.
`Meta+z`|Detach from session.
`Meta+x`|Close window.
`Meta+c`|Close split.
`Meta+v`|Visual selection. `y` to copy.
`Meta+f`|None.
## Nvim.
Key|Action
---|---
`Space+Esc`|None.
`Space+q`|Switch to the left buffer.
`Space+e`|Switch to the right buffer.
`Space+Q`|Move buffer to the left.
`Space+E`|Move buffer to the right.
`Space+\|`|Split vertically.
`Space+-`|Split horizontally.
`Space+w`|Switch to the above split.
`Space+s`|Switch to the below split.
`Space+a`|Switch to the left split.
`Space+d`|Switch to the right split.
`Space+z`|Save all and exit.
`Space+x`|Close buffer.
`Space+c`|Close split.
`Space+v`|Visual selection (or just default `v`).
`Space+f`|None.
More info in [Nvim config.](#nvim-config)
# Nvim config.
TODO: preserve default shortcuts, only add new ones when adding new functionality.
## General info.
* Run `:Update` to update everything.
* File tree shows everything by default, telescope ingores git-ignored files.
## Keymaps.
### Common. TODO: separate visual and others from common.
Mode|Key|Action
---|---|---
Normal, Visual|`5dd`|Repeat following command N (5) times.
Normal|`.`|Repeat input on selected line.
Normal, Visual|`<Leader>.`|Repeat command on selected line(s).
Normal|`zz`|Save all files.
Normal|`ZZ`, `<Space>z`|Save all and quit.
Normal|`ZQ`|Quit without saving.
Normal|`v`, `<Space>v`|Visual selection (cursor).
Normal|`V`|Visual selection (lines).
Normal|`<C-v>`|Visual selection (block).
Normal|`gh`|Go to the start of the line.
Normal|`gl`|Go to the end of the line.
Normal|`gj`|Go to the end of the file.
Normal|`gk`|Go to the top of the file.
Normal|`u`|Undo action.
Normal|`U`|Redo action (*remaps*: undo whole line), (*default*: `<C-r>`).
Visual|`u`|Convert selection to lowercase.
Visual|`U`|Convert selection to uppercase.
Visual|`~`|Toggle case.
Normal, Visual|`;`|Enter command mode (*default*: `:`).
Normal|`<Space>0`|Open shortcuts help.
### Align.
Mode|Key|Action
---|---|---
Visual|`<Space>A`|Align selection from the right.
Visual|`<Space>a`|Align selection from the left.
### Autocomplete.
Mode|Key|Action
---|---|---
Input|`<C-Space>`|Autocomplete.
Normal|`<C-Space>`|LSP autocomplete.
### Comments.
Mode|Key|Action
---|---|---
Normal, Visual|`<Space>/`|Toggle selected line(s) comment.
### File tree.
Mode|Key|Action
---|---|---
Normal|`<Space>1`|Toggle file tree.
Normal|`<Tab>`|Toggle directory or open file for preview.
Normal|`a`|Create file/directory.
Normal|`x`|Cut file/directory.
Normal|`p`|Paste file/directory.
Normal|`f`|Filter.
Normal|`F`|Reset filter.
Normal|`d`|Delete file/directory.
Normal|`r`|Rename file.
Normal|`R`|Refresh.
Normal|`s`|Open in system app.
Normal|`S`|Search.
Normal|`I`|Toggle gitignore filter.
Normal|`y`|Copy name.
Normal|`Y`|Copy relative path.
### Fold.
Mode|Key|Action
---|---|---
Normal|`<Space>o`|Toggle fold.
Normal|`<Space>O`|Fold everything.
### Git.
Mode|Key|Action
---|---|---
Normal|`<Space>g`|Toggle git inspection mode.
### Macros.
Mode|Key|Action
---|---|---
Visual|`mwu`|Unwrap selection (select the stuff inside wraps).
Visual|`mw"`|Wrap selection in ".
Visual|`mw3"`|Wrap selection in 3x ".
Visual|`mw'`|Wrap selection in '.
Visual|`mw(`|Wrap selection in ().
Visual|`mw{`|Wrap selection in {}.
Visual|`mw[`|Wrap selection in [].
Visual|`` mw` ``|Wrap selection in \`.
Visual|`` mw3` ``|Wrap selection in 3x \`.
Visual|`mw*`|Wrap selection in *.
Visual|`mw2*`|Wrap selection in 2x *.
Visual|`mw3*`|Wrap selection in 3x *.
Normal, Visual|`mmx`|Markdown: set - [ ] as completed.
Normal, Visual|`mm `|Markdown: set - [x] as not completed.
Normal|`mmp`|Markdown: insert paragrapg (2x non-breakable spaces).
Visual|`mmb`|Markdown: make selection bold.
Visual|`mmi`|Markdown: make selection italic.
Visual|`mms`|Markdown: make selection strikethrough.
Visual|`mmr`|Markdown: make selection a reference.
Visual|`mmc`|Markdown: make selection a code block.
Normal|`mi`|Copy and increment selected line.
Normal|`ma`|Select all.
### Navigation.
Mode|Key|Action
---|---|---
Normal|`<Space>w`|Switch to the split above.
Normal|`<Space>a`|Switch to the split left.
Normal|`<Space>s`|Switch to the split below.
Normal|`<Space>d`|Switch to the split right.
Normal|`<Space>q`|Swtich to the buffer left.
Normal|`<Space>e`|Swtich to the buffer right.
Normal|`<Space>Q`|Move the buffer left.
Normal|`<Space>E`|Move the buffer right.
Normal|`<Space>x`|Close the buffer.
Normal|`<Space>X`|Close all invisible buffers.
Normal|`<Space>m`|Move split.
Normal|`<Space>\|`|Split vertically.
Normal|`<Space>-`|Split horizontally.
Normal|`<Space>c`|Close split.
Input|`<C-h>`|Move left.
Input|`<C-l>`|Move right.
Input|`<C-j>`|Move down.
Input|`<C-k>`|Move up.
### Telescope.
Mode|Key|Action
---|---|---
Normal|`<Space>ff`|Find files.
Normal|`<Space>fg`|Find grep (find text within files).
Normal|`<Space>fb`|Find buffer.
Normal|`<Space>fh`|Find help.
Normal|`<Space>ft`|Find treesitter (vars, functions etc).
Normal|`<Space>fa`|Find all (default treesitter window).
### Terminal.
Mode|Key|Action
---|---|---
Normal|`<Space>4`|Open terminal.
Terminal|`<Esc>`|Detach from terminal.
### To-do.
Write `TODO:` or `NOTE:` to make it searchable.
Mode|Key|Action
---|---|---
Normal|`<Space>3`|Open to-do list.
### Trouble.
Mode|Key|Action
---|---|---
Normal|`<Space>2`|Open LSP trouble list.
### Which key.
Mode|Key|Action
---|---|---
Normal|`<Space>0`|Show context hotkey help.
### Window management.
Mode|Key|Action
---|---|---
Normal|`-`|Decrease split size vertically.
Normal|`_`|Increase split size vertically.
Normal|`\`|Decrease split size horizontally.
Normal|`\|`|Increase split size horizontally.
Normal|`<Space>=`|Equalize split sizes.
# Bash commands.
## Android.
Command|Description
---|---
`emulator`|Start android emulator. Not portable, it has to be named "default".
## Archive.
Those are self-written scripts to create archives. They are basically compressed tar archives with SHA1 hashes in their names. They are exported so also available in `parallel` like this: `ls | parallel -j 8 -- archive {}`
Command|Description
---|---
`archive [FILES]`|Create archive with the best compression (slow). If no args given, archives all files in current directory as separate archives.
`archive_fast [FILES]`|Like normal `archive` but with minimal compression.
`archive_check [ARCHIVES]`|Check specified archives or all archives in current directory.
`archive_name [ARCHIVES] [NAME]`|Rename specified archive ro specified name or simplify name for specified archive or simplify names for all archives.
`unarchive [ARCHIVES]`|Check specified or all archives and extract if they are correct.
## Autocomplete.
Thos are functions that provide tab-completions.
```bash
_foo()
{
_autocomplete "{foo,bar}"
}
complete -F _foo foo
```
Command|Description
---|---
`_autocomplete <ARGS>`|Provide completion based on provided arguments separated by spaces.
`_autocomplete_first <ARGS>`|Same as `_autocomplete` but works only once for first argument.
`_autocomplete_grep <PATTERN>`|Ls autocomplete with specified grep filter.
`_autocomplete_nested`|Provides nested completions, just like `sudo` does.
## Battery.
Command|Description
---|---
`battery_level`|Print battery charge level (if available).
## Bootstrap.
Shortcuts to install different stuff.
Command|Description
---|---
`bootstrap_cargo`|Install cargo.
`bootstrap_texlive`|Install TeXLive package.
`bootstrap_grub`|Install grub theme. Requires root.
`bootstrap_ffmpeg`|Install ffmpeg in flatpak to make `~/app/bin/ffmpeg` work.
## Checksum.
Command|Description
---|---
`checksum new`|Create checksums recursively.
`checksum check`|Check previously created checksums.
## Chmod.
Command|Description
---|---
`x <FILE>`|Make file executable.
## Color.
### How to use.
Most of the time you want to use it with `echo`. To make `echo` respect colors, you need to use `-e` flag like that:
```bash
export color_default="\033[0m"
export color_red="\033[0;31m"
echo -e "${color_red}hello world!${color_default}" # will print "hello world!" in red.
```
Don't forget to use `color_default` at the end, or your whole terminal will be red.
### List of colors.
Please note that colors depend on Terminal Emulator and may vary based on its settings.
|Color|Code|
|---|---|
|default|`\033[0m`|
|blue|`\033[0;34m`|
|blue (bold)|`\033[1;34m`|
|cyan|`\033[0;36m`|
|cyan (bold)|`\033[1;36m`|
|green|`\033[0;32m`|
|green (bold)|`\033[1;32m`|
|purple|`\033[0;35m`|
|purple (bold)|`\033[1;35m`|
|red|`\033[0;31m`|
|red (bold)|`\033[1;31m`|
|white|`\033[0;37m`|
|white (bold)|`\033[1;37m`|
|yellow|`\033[0;33m`|
|yellow (bold)|`\033[1;33m`|
## Copy/paste.
Command|Description
---|---
`echo a \| copy`|Copy `a` to system clipboard.
`paste > file.txt`|Paste system clipboard to a file (or pipe).
## File copy (cp).
Command|Description
---|---
`cp <FROM> <TO>`|Copy files or dirs. Actually, it is an alias for `rsync -ahP`. Multiple `<FROM>` could be specified.
`cp_merge <FROM> <TO>`|Mirror directories. Same as `rsync --delete`.
`cp_link <FROM> <TO>`|Copy directory by recursively creating hardlinks and directories.
`bcp <FROM> <TO>`|Default `cp` command.
## Date.
Command|Description
---|---
`today`|Return today's date in `YYYYmmdd` format.
`dow`|Return today's day of week, where 1 is Monday.
## Dconf (gnome settings).
Command|Description
---|---
`dconf_load`|Load custom settings.
`dconf_save`|Export all current setting in a file to inspect.
## Disk.
Command|Description
---|---
`df`|Show free disk space (only physical media).
`du [FILES]`|Show disk usage.
## Docker.
Command|Description
---|---
`docker_volumes <CONTAINER>`|Show volumes of a specified container.
`docker_health`|Show containers that exited with an error code.
`docker_prune`|Heavy cleanup to free up space.
`docker_ip <CONTAINER>`|Show IP of a specified container.
`docker_update`|Update all Docker images.
`dc`|Short for `docker compose`.
`dcu [SERVICE]`|Start a compose service.
`dcd [SERVICE]`|Remove a compose service.
`dcp [SERVICE]`|Pull image for a compose service.
`dcl [SERVICE]`|Show logs for a compose service.
`dcr [SERVICE]`|Restart a compose service.
`dcs [SERVICE]`|Stop a compose service.
`dcdu [SERVICE]`|Recreate a compose service.
`dcpu [SERVICE]`|Update and recreate a compose service.
`dcul [SERVICE]`|Start a compose service and show its logs.
## Pack.
Command|Description
---|---
`pack <TARGET.ext> <FILES>`|Create desired file format with other files.
`unpack <FILES>`|Attempt to extract file content.
## Environment variables.
Variable|Description
---|---
`PATH`|Defines where to find binaries. Modified to also include `$HOME/app/bin/` recursively.
`LANGUAGE`|Specifies `UTF-8` as default.
`EDITOR`|Specifies nvim as a default editor.
`MANPAGER`|Specifies nvim as a default `man` viewer.
`JAVA_HOME`|Specifies where JDK is stored.
`ANDROID_SDK_ROOT`|Specifies where Android SDK is stored.
`TEXMFVAR`, `TEXMFCONFIG`, `TEXMFLOCAL`|Specifies paths for TeXLive user directories.
## Ffmpeg.
Command|Description
---|---
`ffmpeg_mux_audio <SOUND> <RESULT>`|Mux external audio into one container with video (replaces original audio). Run inside dir with original video. <SOUND> names should be the same for each video.
## Files.
Command|Description
---|---
`o <FILE>`|Open file with default GUI app.
## Fix.
Contains simple fixes for warious issues.
Command|Description
---|---
`fix_ethernet_speed <SPEED>`|Specify ethernet speed if it failed to set correct speed automatically. [SPEED] can be 10/100/1000 etc.
`fix_files_sftp`|Make Nautilus forget incorrect password for SFTP connection.
## Git.
Command|Description
---|---
`git_tag`|Print git tag.
`gps`|Git push.
`gpsf`|Git push --force.
`gpl`|Git pull.
`gl`|Git log.
`gs`|Git status.
`gst`|Git stash.
`gd`|Git diff.
`gc [MESSAGE]`|Git commit.
`gch`|Git checkout.
`gchb`|Git checkout branch.
`gb`|Git branch.
`gbd [BRANCH]`|Delete specified Git branch.
`gf`|Git fetch --all.
`gt`|Git tag.
`gi`|Delete files updated in git ignore.
`gpc`|Git patch create.
`gp`|Git patch (apply).
`ga`|Git add with preview.
`gr [COUNT]`|Git rebase. 2 last commits by default. 0 means from root.
`gu [EMAIL]`|Configure git user as Dmitry Voronin with specified email (project).
## Ls.
Command|Description
---|---
`l`|List files in current dir.
`ll`|List including hidden files.
`lll [DEPTH] [PATH]`|Show file tree.
`llll`|List everything recursively.
`la`|List alphabetically.
`laa`|List all alphabetically.
## Name.
Those are scripts to manipulate file names. They are all exported and available for `parallel`. If no [FILES] specified, it applies to all files inside current directory.
Command|Description
---|---
`name [FILES]`|Replace all non-alphanumeric characters in file with underscores.
`name_hash [FILES]`|Replace all file names with hashes, keep extension.
`name_hash_check [FILES]`|Check all file hashes.
`name_series <SEASON>`|Rename files to Jellyfin's show format: `Episode S01E01.mkv`.
`name_manga <SEASON>`|Rename files to Kavita's manga format: `Name Vol.1 Ch.01.cbr`.
`name_ext <EXTENSION> [FILES]`|Change file extensions.
## Ncdu.
Command|Description
---|---
`ncdu [DIR]`|Show recursive disk usage. Only on the same filesystem.
## Notify.
Command|Description
---|---
`notify <MESSAGE>`|Send notification.
`notify_silent <MESSAGE>`|Send silent notification.
## Own.
Command|Description
---|---
`own [USER] [FILE]`|Change ownership & permissions to specified user. Ownership changes only when root.
## Permissions.
Command|Description
---|---
`perm`|Recursively change permissions not to share: 700 for dirs and 600 for files.
`perm_share`|Recursively change permissions to share: 755 for dirs and 644 for files.
## Ps.
Command|Description
---|---
`ps <PROGRAM>`|Show process info for matching [PROGRAM] name.
## Recursive.
Command|Description
---|---
`recursive <COMMAND>`|Cd into every directory recursively and run specified command in each dir.
## Shopt.
Shopt|Description
---|---
`dotglob`|When using `*` to match files, hidden files that start with a dot are also included.
`globstar`|Allows the use of `**` for recursive search.
`autocd`|Change directories without writing `cd`.
## Su.
Command|Description
---|---
`s`|An alias for `su` cause I'm lazy.
## Terminal.
Command|Description
---|---
`tsize`|Prints terminal size.
## Tmux.
Command|Description
---|---
`ta [NAME]`|Attach to session by name. Default is `main`.
`td`|Detach from session.
`tl`|List all sessions.
`tr`|Rename session.
`tn`|Name window.
`tk [NAME]`|Kill session. Default is `main`.
`tka`|Kill all sessions.
## To-do.
Command|Description
---|---
`todo`|Open editor for `~/.todo.md` file.
## Toolbx.
Command|Description
---|---
`tb [NAME]`|Attach to box by name. Default is `main`.
`tbk [NAME]`|Kill box by name. Default is `main`.
`tb_rpmfusion [NAME]`|Install RPMFusion package to box by name. Default is `main`.
`tbl`|List all boxes.
## Try.
Command|Description
---|---
`try <COMMAND>`|Repeat the command every 2 seconds until it exits with success.
## Umask.
By default, umask is `077` which means group and others have no access when files are created.
## Vdl.
Command|Description
---|---
`vdl <LINK>`|Download video/playlist.
`vdl_file <FILE>`|Download all links from a file.
`vdl_update`|Update playlist that was downloaded with `vdl` before.
`vdl_update_all`|Recursive `vdl_update`.
## Vi.
Command|Description
---|---
`vi`, `v`|Aliases for `nvim`.
## Wallpaper.
Command|Description
---|---
`wallpaper <FILE>`|Set specified file as a wallpaper.
## Watch.
Command|Description
---|---
`w <COMMAND>`|Alias for `watch`.
`ww <COMMAND>`|Alias for `watch` that updates every 0.1 seconds.
# To-do.
- [ ] Add tmux shortcuts to <C-t> combo, too.