mirror of
https://github.com/donovanglover/nix-config.git
synced 2024-11-25 09:43:11 +01:00
Remove help files
Since this repository is specifically for my dotfiles, I have removed all help files. I may re-publish them in another form in the future.
This commit is contained in:
parent
c771722d38
commit
782cf59847
258
help/commands.md
258
help/commands.md
@ -1,258 +0,0 @@
|
||||
## Common Commands
|
||||
|
||||
- Move files: `mv <source> <dest>`
|
||||
- Move directories: `mv -r <source> <dest>`
|
||||
- Copy files: `cp <source> <dest>`
|
||||
- Copy directories: `cp -r <source> <dest>`
|
||||
- Copy all files from one directory to an existing directory (includes dotfiles and subdirectories): `cp -R dir_1/. dir_2/`
|
||||
|
||||
Note that "renaming" files is the same as moving them from one location to another. For example, if you want to rename a file `oldfile` to `newfile`, then you would type `mv oldfile newfile`.
|
||||
|
||||
- Print the contents of a file: `cat <filename>`
|
||||
- Batch rename multiple files: `rename -v <find_this_string> <replace_with_this_string> <in_these_files>`
|
||||
- Remove (delete) files: `rm <filename>`
|
||||
- Remove (delete) a directory: `rm -r <dirname>`
|
||||
- Make a new file: `touch <filename>`
|
||||
- Make a new directory: `mkdir <dirname>`
|
||||
- List all the files in a directory: `ls` **OR** `find`
|
||||
- List all the directories in a directory: `ls -d */`
|
||||
- List all the files in a directory, including dotfiles: `ls -A`
|
||||
- List all the files in dirname: `ls <dirname>`
|
||||
- Only list png and jpg files: `ls *.{png,jpg}`
|
||||
- Print the file type based on header information: `file <filename>`
|
||||
- Show all running processes as a tree: `pstree`
|
||||
- Print the number of lines in a file: `wc -l <file>`
|
||||
- Print the length of the longest line in a file: `wc -L <file>`
|
||||
- Print the number of words in a file: `wc -w <file>`
|
||||
- Print the number of lines in all markdown files in a given directory, including subdirectories: `find . -name "*.md" | xargs wc -l`
|
||||
- Show the size of the current directory, including subdirectories: `du -h`
|
||||
- Show the size of the current directory and its files: `du -ha`
|
||||
- Get more information about any command: `man <command>`
|
||||
|
||||
## Switching Directories
|
||||
|
||||
- Go up one directory: `..`
|
||||
- Go up two directories: `...`
|
||||
- Go to the home directory: `~` OR simply `cd` with no parameters
|
||||
- Go to dirname: `dirname`
|
||||
|
||||
Note that for all of the above, `cd` is not required.
|
||||
|
||||
### Other Commands
|
||||
|
||||
- Print the working directory: `pwd`
|
||||
- Termite the processes with a specific word in it: `killall -q <word>`
|
||||
- Get the current time and settings: `timedatectl`
|
||||
- Show what gets executed when you run a command: `which <command>`
|
||||
- Create a symbolic (soft) link between two files: `ln -s <source> <dest>`
|
||||
- When a program references `dest`, it will link to and give `source`.
|
||||
- In comparison, a hard link is when you make a copy of the file
|
||||
- Give permissions to the user `hello` and the group `world`: `chown -R hello:world dir/`
|
||||
- Given text input, return only unique lines (aka no duplicates): `cat <input_file> | uniq`
|
||||
- Search for a particular font on the system: `fc-list | grep -i <font>`
|
||||
- Search for all files of a specific extension in a given directory: `find . -name "*.ext" -type f`
|
||||
- Chain `-delete` to the end of the find command in order to delete the results
|
||||
- This is useful if, for example, you want to delete all files with the extension `ext` in all directories and subdirectories
|
||||
- Show what gets called when you execute a command: `type <command>`
|
||||
- Show everything that is aliased to a given command: `type -a <command>`
|
||||
|
||||
### Changing File Permissions
|
||||
|
||||
- Make a script executable: `chmod +x <file>`
|
||||
- Change the permissions of a directory to all users: `chmod -R a+rwX dir/`
|
||||
- Give anyone and everyone access to a directory: `chmod -R 777 dir/`
|
||||
- Useful for deleting files that the current user can't delete
|
||||
|
||||
Note that you should *never* give a file or directory more permissions than needed. `a+rwX` and `777` should only be used in extreme situations where you have to change permissions before using a file. You should change the permissions back or delete the file when you're done.
|
||||
|
||||
### Searching Through Files
|
||||
|
||||
- Search all files in a directory (and all subdirectories) for a given string: `grep -inr <search_term>` **OR** `g <search_term>`
|
||||
- Search all files in a directory (including subdirectories) for a given string and ignore dotfiles: `rg <search_term>`
|
||||
|
||||
### System Commands
|
||||
|
||||
- Logout of the current user session: `logout`
|
||||
- Restart the system: `reboot`
|
||||
- Turn off the computer: `poweroff`
|
||||
|
||||
## Installed Commands
|
||||
|
||||
These programs are installed on top of the base system.
|
||||
|
||||
- List the entire contents of a directory: `tree`
|
||||
- List all the directories in a directory, up to 2 levels deep: `tree -d -L 2`
|
||||
- Beautify any JSON output: `<json_output> | jq '.'`
|
||||
- Easily search for a file in a directory and its subdirectories: `fzf`
|
||||
- Show duplicate files in a given directory, with the ability to remove them as well: `fdupes <dir>`
|
||||
- Add `-r` to go through subdirectories
|
||||
- Add `-n` to exclude empty files
|
||||
- Add `-f` to omit the first file in each set of matches
|
||||
- Add `-1` to list each set of matches on a single line
|
||||
- Add `-S` to show the size of each duplicate file
|
||||
- Add `-d` to delete duplicates during execution
|
||||
- Add `-A` to ignore hidden files
|
||||
- Search for all files of a specific extension in a given directory, recursively: `fd -e ext`
|
||||
- Get the DNS record of a certain domain: `dig <domain>`
|
||||
- Add `+short` to return a shortened version of the result
|
||||
- Add `-t <type>` to return a specific type in the result (e.g. `-t txt`)
|
||||
|
||||
### Inox
|
||||
|
||||
- Open a webpage in a borderless window: `inox --app=<url>`
|
||||
- Open a webpage in the regular browser window: `inox <url>`
|
||||
|
||||
### Waterfox
|
||||
|
||||
- Open a webpage in a new window: `waterfox --new-window <url>`
|
||||
- Open a webpage in a new tab: `waterfox --new-tab <url>`
|
||||
- Search for a specific term: `waterfox --search <term>`
|
||||
|
||||
### Jekyll
|
||||
|
||||
- Start a server and monitor it for changes (useful for development): `jekyll serve`
|
||||
- Start a server and detach it from the current shell: `jekyll serve --detach`
|
||||
- Terminate a jekyll server that was detached from the shell: `kill -9 <pid>`
|
||||
- Terminate all jekyll servers: `pkill -f jekyll`
|
||||
|
||||
Note that you can run multiple servers on different ports through Jekyll and other software.
|
||||
|
||||
### Crystal
|
||||
|
||||
- Build and run the program directly: `crystal <file>`
|
||||
- Compile the program to binary: `crystal build <file>`
|
||||
- Add `--progress` or `-p` to show build progress
|
||||
- Add `--release` when you're building the release version (takes longer)
|
||||
- Add `--no-debug` to increase the build speed (useful for dev builds)
|
||||
- Add `-o` to specify the location of the output file
|
||||
|
||||
### LaTeX
|
||||
|
||||
- Make a pdf of your document: `pdflatex <file>`
|
||||
- Add `-output-directory <dir>` to specify the location for build files (`.aux`, `.pdf`, `.log`, etc.)
|
||||
- The directory `<dir>` must exist before you can write to it
|
||||
- Note that all `pdflatex` options must come before specifying `<file>`
|
||||
|
||||
### Xclip
|
||||
|
||||
**Using the X clipboard**
|
||||
|
||||
- Copy the result of any command to the X clipboard: `command | xclip`
|
||||
- This is particularly useful for commands like `fzf`, where you want to search for a specific file then do something with it
|
||||
- Paste the results from the X clipboard: `xclip -o`
|
||||
|
||||
**Using the global clipboard**
|
||||
|
||||
- Copy a file to the global clipboard: `xclip -sel clip < filename.txt` **OR** `cat filename.txt | xclip -sel clip`
|
||||
- Note that `-sel` is shorthand for `-selection` and that `clip` is shorthand for `clipboard`
|
||||
- Copy the result of any command to the global clipboard: `command | xclip -sel clip`
|
||||
- Paste the results from the global clipboard: `xclip -o -sel clip`
|
||||
|
||||
### Secure Shell
|
||||
|
||||
- Make a new 4096-bit RSA key: `ssh-keygen -t rsa -b 4096 [-C <comment>]`
|
||||
- Note that `id_rsa` is your private key and `id_rsa.pub` is your public key
|
||||
- Add your new key to SSH: `ssh-add ~/.ssh/id_rssa`
|
||||
- Copy your public key: `xclip -sel clip < ~/.ssh/id_rsa.pub`
|
||||
- Add a location to your known hosts: `ssh -T <location>`
|
||||
- For example, if you wanted to use SSH with GitHub, you would add the location `git@gitlab.com`
|
||||
- Start the SSH agent: `eval "$(ssh-agent -s)"`
|
||||
|
||||
Note that a git repository must be cloned with SSH if you want to use SSH with it.
|
||||
|
||||
### Dealing with Archives
|
||||
|
||||
- Zip all files in a directory: `zip -r <zip_name> <directory>`
|
||||
- View the contents of rar files: `unrar lb <files>`
|
||||
- Extract the contents of rar files: `unrar x <files>`
|
||||
- Extract the contents of zip files: `unzip <files>`
|
||||
- Extract the contents of a tgz file: `tar -xvzf file.tgz`
|
||||
- Extract any type of archiving algorithm: `extract <filename>`
|
||||
- Recursively create a new directory for each zip file in the current directory to extract to: `for f in *.zip; do unzip -d "${f%*.zip}" "$f"; done`
|
||||
- Note that you should not use this command if the zip archive contains a directory
|
||||
|
||||
**Note**: When using `unrar` or `unzip` to extract multiple files (with wildcards), you must first escape the `*` to `\*`.
|
||||
|
||||
### Opening Things
|
||||
|
||||
Note that the preferred way to open things is with the `open` function; however, sometimes it is necessary to use these commands if, for example, you're loading an entire directory.
|
||||
|
||||
- Open a video or multiple videos in a playlist: `mpv <files/dir>`
|
||||
- Open an image or multiple images: `feh <files/dir>`
|
||||
- Add `-r` to recursively iterate through all subdirectories
|
||||
- Add `-z` to randomize the order of the images
|
||||
- Use `-l` to enable list mode, an easy way to see various details about images
|
||||
- Use `-t` to enable thumbnail mode, a quick and easy way to see all the images in a directory
|
||||
- Add `-E <pixels>` to set the thumbnail height
|
||||
- Add `-y <pixels>` to set the thumbnail width
|
||||
- Note that generating thumbnails takes time (i.e. don't use with large file sizes)
|
||||
|
||||
### Firejail
|
||||
|
||||
Use `firejail` to sandbox a program or other piece of software. This ensures that the program does not have access to your entire file system since it runs in a restricted environment.
|
||||
|
||||
- Run a program in firejail with its default profile (if it exists): `firejail <program>`
|
||||
- Use firejail by default for all programs that have profiles: `firecfg`
|
||||
- List all the programs that use firejail by default: `firecfg --list`
|
||||
- Remove all symbolic links to firejail: `firecfg --clean`
|
||||
- Verify that firejail is being used for a particular program: `firejail --list`
|
||||
|
||||
### ImageMagick
|
||||
|
||||
- Resize an image to 50% of its original size: `convert -resize 50% <given_img> <output_img>`
|
||||
- Resize an image to a specific size: `convert -resize 1280x720 <given_img> <output_img>`
|
||||
- Resize all png files in a directory to 800x600: `mogrify -resize 800x600 *.png`
|
||||
|
||||
Note that you should use `mogrify` instead of `convert` when you want to change images directly.
|
||||
|
||||
### Pacman
|
||||
|
||||
Although the examples below use `pacman`, they apply for `yay` as well.
|
||||
|
||||
- Install packages: `pacman -S <packages>`
|
||||
- Remove packages (including dependencies no longer needed): `pacman -Rs <packages>`
|
||||
- Update all packages: `pacman -Syu`
|
||||
- Search for a specific package: `pacman -Ss <package>`
|
||||
- List all installed packages: `pacman -Q`
|
||||
- List all the packages installed as dependencies: `pacman -Qd`
|
||||
- List all self-installed packages (i.e. from the AUR): `pacman -Qm`
|
||||
- Display information about a specific package: `pacman -Qi <package>`
|
||||
- List all the files owned by a specific package: `pacman -Ql <package>`
|
||||
- Install a package from a local file: `pacman -U /path/to/pkg.ar.gz`
|
||||
|
||||
Note that if you ever get 404s with `pacman` or `yay`, you need to update your local database to the new download locations with `-Syu` first.
|
||||
|
||||
#### Yay-specific Commands
|
||||
|
||||
- Remove unneeded dependencies: `yay -Cd`
|
||||
- Show statistics about installed packages: `yay -Qstats`
|
||||
|
||||
#### Other Pacman Variants
|
||||
|
||||
- View the dependencies of a package in tree format: `pactree -c <package>`
|
||||
- Add `-d 1` to limit the depth of the tree to one level deep
|
||||
- List all the packages that depend on a certain package: `pactree -rc <package>`
|
||||
- Remove all cached versions of packages except the most recent one: `paccache -rk1`
|
||||
- Remove all cached versions of uninstalled packages: `paccache -ruk0`
|
||||
|
||||
### Working with Online Resources
|
||||
|
||||
- Download anything online: `wget <url>`
|
||||
- View the response header and contents of any webpage: `http <url>`
|
||||
|
||||
## Custom Commands
|
||||
|
||||
- Easily switch to a 4k resolution with DPI scaling: `4k`
|
||||
- Easily switch to a 1080p resolution (with 96 DPI): `1080p`
|
||||
- Run a command as root: `pls <command>`
|
||||
- Run the previous command as root: `pls !!`
|
||||
|
||||
## Startup Commands
|
||||
|
||||
- Turn the screensaver off and disable DPMS: `xset s off -dpms`
|
||||
- Sync the system time with one on the internet: `sudo synctime`
|
||||
- Launch Polybar `~/.config/polybar/launch.sh`
|
||||
|
||||
## Working with Audio
|
||||
|
||||
- Convert a mp4 video to mp3 audio: `ffmpeg -i video.mp4 -vn -acodec libmp3lame -ac 2 -ab 192k -ar 48000 audio.mp3`
|
157
help/git.md
157
help/git.md
@ -1,157 +0,0 @@
|
||||
# Git
|
||||
|
||||
## Common commands
|
||||
|
||||
- Start a new git repository: `git init` **OR** `gi`
|
||||
- Clone a git repository from an upstream url: `git clone <url>`
|
||||
- Add `--depth N` to only fetch the last N commits (useful when you don't need the older commits)
|
||||
- Add files to commit: `git add <files>` **OR** `ga <files>`
|
||||
- Commit those files to the repository: `git commit -m <message>` **OR** `gc <message>`
|
||||
- Undo the last commit and keep the changes: `gr` **OR** `git reset HEAD~`
|
||||
- Undo the last soft git reset: `git reset 'HEAD@{1}'`
|
||||
- Undo the last commit and delete changes: `grr`
|
||||
- Also known as a "hard" git reset
|
||||
- Update your local repository with a remote repository: `git pull <remote> <branch>`
|
||||
- Most of the time you'll be using `origin master` to pull from your remote repository and `upstream master` to pull from the upstream repository
|
||||
- This is the equivalent of clicking "accept pull request" on GitHub
|
||||
- Show the status of the local repository: `git status` **OR** `gs` **OR** `git s`
|
||||
- Push changes from your local repository to a remote repository: `git push <remote> <branch>` **OR** `git push` **OR** `gp`
|
||||
- The most common use is `git push origin master`, which is usually the default for `git push`
|
||||
- Show the difference between the staging area and the working tree: `git diff` **OR** `gd`
|
||||
- Show the changes that you added but haven't committed yet: `git diff --staged` **OR** `gd --staged` **OR** `gds`
|
||||
- Show a log of all the commits: `git log` (full log) **OR** `git lg` (commits only, easier to read)
|
||||
- Edit the last commit message: `git commit --amend`
|
||||
- To add new file changes to a previous commit, simply `git add` those files before using `git commit --amend`
|
||||
- Commit a file one part at a time: `git add --patch <file_name>` **OR** `ga --patch <file_name>` **OR** `gap <file_name>`
|
||||
- Useful when you made a lot of changes to a file and need to commit it
|
||||
- Enables you to commit certain parts of a file and not the entire thing
|
||||
- Note that if the file is not in the repository yet, you should do `git add -N <file_name>` or `ga -N <file_name>`
|
||||
- Go to the next section: `j`
|
||||
- Go to the previous section: `k`
|
||||
- Stage this section for the next commit: `y`
|
||||
- Do not stage this section for the next commit: `n`
|
||||
- Quit and do not stage this section or any of the remaining sections: `q`
|
||||
- Split the current section into smaller sections: `s`
|
||||
- Manually edit the current section: `e`
|
||||
|
||||
Note that the `-u` flag means `set-(u)pstream-to`. It records the location so you don't have to set which remote to push or pull from every time.
|
||||
|
||||
Also note that `git clone` makes a remote name of `origin` by default. This is why `git push -u origin master` is usually used.
|
||||
|
||||
### Working with Branches
|
||||
|
||||
- Show all the branches: `git branch -a`
|
||||
- Checkout a different branch: `git checkout <branch>`
|
||||
- Useful for 1) checking out the master or development branch, 2) checking out an upstream branch, and 3) checking out a feature branch
|
||||
- Create a new branch: `git checkout -b <branch>`
|
||||
- Use `<group>/<description>` to describe your branches
|
||||
- For example, a fix for a compiler issue should have a branch name of `fix/description-of-compiler-issue`
|
||||
- Note that the branch should be descriptive but not too long (i.e. don't make it longer than above, since the example above is pretty long already)
|
||||
- Always create a new branch when submitting pull requests. This allows you to create multiple pull requests for different issues, prevent conflicts between your master branch and upstream, as well as some other things.
|
||||
- Delete a branch when you're done with it: `git branch -d <branch>`
|
||||
- Delete a remote branch: `gp -d <remote> <branch>`
|
||||
- Push your changes to a different branch (i.e. your new branch): `git push origin <branch>` **OR** `gp origin <branch>`
|
||||
- Rename the current branch: `git branch -m <new_name>`
|
||||
|
||||
### Updating a Forked Repository
|
||||
|
||||
If you haven't already, make sure that you have added a remote to the original (upstream) repository: `git remote add upstream <location>`
|
||||
|
||||
1. Fetch all the branches of that remote into `upstream/<branch>`: `git fetch upstream`
|
||||
2. Change to the branch that you want to update (usually master): `git checkout master`
|
||||
3. Rewrite that branch (usually master) with the changes upstream: `git rebase upstream/master`
|
||||
|
||||
If a lot of people have forked your repository, then it may be better to use `git merge upstream/master` instead. This avoids rewriting history, but at the cost of clean pull requests.
|
||||
|
||||
It may be necessary to force push your changes with `git push -f origin <branch>` (usually master).
|
||||
|
||||
Note that you should always make changes from an external branch then make a pull request from your external branch to avoid rewriting history.
|
||||
|
||||
If you need to update your local repository but have local changes, you need to stash them first.
|
||||
|
||||
1. First fetch upstream like usual.
|
||||
2. Then use `git stash` to store your changes temporarily.
|
||||
3. Next rebase the branch you want to update with `upstream/<branch>` (usually master).
|
||||
4. Finally use `git stash pop` to update your repository with the stashed changes.
|
||||
|
||||
**NOTE**: To undo a git rebase, use `git reset --hard ORIG_HEAD`
|
||||
|
||||
To fetch a specific branch from any repository (e.g. your repository):
|
||||
|
||||
1. Fetch the changes into a new branch: `git fetch <remote> <name_of_remote_branch>:<name_for_the_local_branch>`
|
||||
2. Checkout that branch: `git checkout <name_you_made_for_the_local_branch>`
|
||||
|
||||
## Less common commands
|
||||
|
||||
- Removes files to commit: `git rm <files>`
|
||||
- Delete all local changes in the repository: `git clean -f`
|
||||
- Show all the diffs and changes from the last N commits: `git log -p -<N>`
|
||||
- Show the differences between your repository and a remote one: `git log -p master..<remote>/master`
|
||||
- View all remotes for the current repository: `git remote -v` (e.g. GitHub mirror, friend's fork, upstream, etc.)
|
||||
- Show the location of a remote in a repository: `git ls-remote --get-url <remote>`
|
||||
- You can search for `origin` to see the location you cloned from.
|
||||
- Show the entire contents of a commit, including diffs: `git show <commit>`
|
||||
- Search for a string in the files of a git repository: `git grep <pattern>` **OR** `gg <pattern>`
|
||||
- Search for any tab characters in a repository: `git grep $'\t'` **OR** `ggt`
|
||||
- Search for any carriage returns in a repository: `git grep $'\r'` **OR** `ggr`
|
||||
- Merge all unpushed commits into a single commit: `git rebase -i origin/master`
|
||||
- Note that you are not done after this. You must also change `pick` to `squash` (or `s`) for all of the commits you want to merge. This is usually everything except your most recent commit.
|
||||
- Another window will open to let you combine all the commit messages into one big commit message
|
||||
- Merge the current branch with another one (usually master): `git merge <branch>`
|
||||
- Change the remote location if your upstream repository URL changes: `git remote set-url origin git@address:user/repo.git`
|
||||
- Get an idea of how much has changed since the last commit: `git diff --stat`
|
||||
- Rebase the last N commits (i.e. edit them): `git rebase -i HEAD=N`
|
||||
- Apply the commit as-is: `pick`
|
||||
- Edit the commit message: `reword`
|
||||
- Edit the file(s) and/or commit message: `edit`
|
||||
- Merge the commit with the previous commit: `squash`
|
||||
- Merge the commit with the previous commit and discard the commit message: `fixup`
|
||||
- Rename a git directory to use different capitalization (e.g. from uppercase to lowercase): `git mv <old_name> <temp_name>` **THEN** `git mv <temp_name> <new_name>`
|
||||
- Sign all previous commits: `git filter-branch -f --commit-filter 'git commit-tree -S "$@"' HEAD`
|
||||
|
||||
**NOTE:** You should only merge commits with local commits that you haven't pushed yet. Doing this for upstream commits can cause problems for other people that have cloned your repository.
|
||||
|
||||
### Finding Bad Commits
|
||||
|
||||
Before you begin, you should know a commit in which the program was working properly. Since you already know that issue is a part of the current revision, you can use `git bisect` to perform a binary search until the problem commit is found.
|
||||
|
||||
1. Start the search with `git bisect start`
|
||||
2. Build and test the current commit to see if the problem is present.
|
||||
3. If the problem is found, use `git bisect bad`
|
||||
4. Otherwise, use `git bisect good`
|
||||
|
||||
The problem commit is the "first bad commit" found through this process.
|
||||
|
||||
Once you're done with finding the problem commit, use `git bisect reset` to go back to the repository's original state.
|
||||
|
||||
**NOTE**: `git bisect run ./test` is a way to automate this process.
|
||||
|
||||
To see the commits that have been tested so far, use `git bisect log`
|
||||
|
||||
### Working with Tags
|
||||
|
||||
- Show all the tags in a repository: `git tag`
|
||||
- Create a new tag: `git tag -s <tag_name> -m <description>`
|
||||
- If `-m` is not given, git will open your editor to allow you to type a more detailed message
|
||||
- The tag name is usually a version number such as `v2.4.3`
|
||||
- Note that if for some reason you don't want to sign your tag, you should use `-a` instead.
|
||||
- View the saved data of a tag: `git show <tag_name>`
|
||||
- Tag a specific commit instead of the current state in the repository: `git tag -s <tag_name> <commit>`
|
||||
- Push a tag to the remote repository: `git push origin <tag_name>`
|
||||
- Note that sharing a tag is the same as sharing remote branches
|
||||
- Push all tags to upstream: `git push --tags`
|
||||
- Easily change between versions of a repository (through tags): `git checkout <tag_name>`
|
||||
- Update a previous version with new changes: `git checkout -b <branch_name> <tag_name>`
|
||||
- Note that you should make a new tag for the updated commit since `<tag_name>` already refers to a commit and is not changed
|
||||
- For example, if you checkout tag `2.0` then the new tag can be, for example, `2.0.1` or `2.0a`
|
||||
- List all the tags in a given repository: `git tag -l`
|
||||
- Delete a tag (should rarely be used, if ever): `git tag -d <tag_name>`
|
||||
|
||||
### Creating Patches
|
||||
|
||||
You can make patch files for git repositories. This makes it so that other people can use your changes with ease.
|
||||
|
||||
- Create patch files for the last N commits: `git format-patch HEAD~N`
|
||||
- Apply a patch to a git repository (unstaged): `git patch my.patch`
|
||||
- Apply a patch with its commit: `git am my.patch`
|
||||
- Apply all patches with their respective commits: `git am *.patch`
|
175
help/gpg.md
175
help/gpg.md
@ -1,175 +0,0 @@
|
||||
GPG, also known as the GNU Privacy Guard, is a free and open source implementation of the OpenPGP standard.
|
||||
|
||||
## Using GPG
|
||||
|
||||
- You give your *public key* to others so that they can send encrypted messages to you.
|
||||
- You use your *private key* to create a *digital signature* that verifies your identity.
|
||||
|
||||
Your public key and private key are connected to each other. When you combine the two, it becomes possible to write encrypted messages specifically for a specific person as well as verify that a specific person has signed a document or other content.
|
||||
|
||||
More specifically,
|
||||
|
||||
- Other people use your **public key** to:
|
||||
1. **Write** encrypted content to you.
|
||||
2. **Verify** that a signature actually came from you.
|
||||
- You use your **private key** to:
|
||||
1. **Read** encrypted content that people send to you.
|
||||
2. **Sign** documents and other content, verifying their authenticity.
|
||||
|
||||
### Naming Conventions
|
||||
|
||||
- `.key` files are used to store public GPG keys.
|
||||
- `.gpg` files are used to store encrypted contents in binary format.
|
||||
- `.asc` files are used to store encrypted contents in ASCII format.
|
||||
- `.sig` files are used to store GPG signatures created with private keys. They may or may not also include the file content in a compressed or plain text format. Note that `.sig` files are **NOT** encrypted.
|
||||
|
||||
**NOTE**: Signed files that are not encrypted may still be stored as `.gpg` or `.asc`. As a convention that I made up, you should use `.sig.gpg` to signify a signature that has binary-encrypted content and `.sig.asc` to signify a signature that is ASCII-encrypted.
|
||||
|
||||
### Sending Messages
|
||||
|
||||
1. Someone receives your public GPG key and verifies that the key is actually yours.
|
||||
- TODO: Add process of verification here.
|
||||
2. They use your public key to encrypt a message that they send to you.
|
||||
3. They include their public key in the encrypted message so that you can send an encrypted message back to them.
|
||||
4. You receive the encrypted message.
|
||||
5. You use your private key to decrypt the message.
|
||||
6. You use the public key that they sent you to send an encrypted message back to them.
|
||||
|
||||
## Creating Keys
|
||||
|
||||
- Use RSA for the sign only key and RSA for the encrypt only key
|
||||
- Use a keysize of 4096 bits
|
||||
- Make the key valid for one year (1y)
|
||||
- Do not put anything for the comments field
|
||||
- More information: [OpenPGP User ID Comments considered harmful](https://debian-administration.org/users/dkg/weblog/97)
|
||||
|
||||
## Common Commands
|
||||
|
||||
- Generate a new key pair: `gpg --full-gen-key`
|
||||
- List all keys in your public keyring: `gpg --list-keys`
|
||||
- List all keys in your private keyring: `gpg --list-secret-keys`
|
||||
- Export a public key: `gpg -a --export <user_id>`
|
||||
- `-a` is shorthand for `--armor`, which creates ASCII output as opposed to the usual binary format
|
||||
- If you want to output the public key to a file instead of printing it, use: `-o <keyfile>`
|
||||
- Often used so other people can send messages to you with your public key
|
||||
- Import a public key: `gpg --import <keyfile>`
|
||||
- Used so that you can send encrypted messages to other people with their public key
|
||||
- Delete a public key from your keyring: `gpg --delete-keys <user_id>`
|
||||
- Check the fingerprint of a keyfile: `gpg --with-fingerprint <keyfile>`
|
||||
|
||||
**NOTE**: If you import a public key from a keyfile, then you should first check that the fingerprint matches a verified source published by the expected owner of that key *before* adding it.
|
||||
|
||||
## Using a Keyserver
|
||||
|
||||
- Add a public key to the keyserver (permanent): `gpg --send-keys <user_id>`
|
||||
- View the details of a key on the keyserver: `gpg --search-keys <user_id>`
|
||||
- Import a key from the keyserver: `gpg --recv-key <fingerprint>`
|
||||
|
||||
**NOTE**: You should always verify the authenticity of a retrieved public key by comparing its *fingerprint* with one the owner published on at least one *independent source*.
|
||||
|
||||
**NOTE**: Never use a short ID when requesting keys from a keyserver. There have been attacks in the past that abuse the fact that it's trivial to create multiple keys with the same short ID. The long key ID is also prone to this attack. Instead, always use the full fingerprint when receiving a key.
|
||||
- More Information: [OpenPGP Key IDs are not useful](https://debian-administration.org/users/dkg/weblog/105)
|
||||
- Also see: [Evil 32: Check Your GPG Fingerprints](https://evil32.com)
|
||||
|
||||
## Encrypting and Decrypting Things
|
||||
|
||||
- Encrypt a file with someone else's public key: `gpg -R <user_id> -e <file>`
|
||||
- This ensures that only they should be able to read the message and no one else. It is not trivial to guess a private key, making it much harder to brute force than a password.
|
||||
- If you want to encrypt your own files, you can use use `-R <your_user_id>` so that only your private key can decrypt it.
|
||||
- **NOTE**: You should add `-a` before `-e` if you want the encrypted output to be ASCII and not binary.
|
||||
- **NOTE**: You should always use `-R` (hidden-recipient) instead of `-r` to avoid putting the recipient key IDs in the encrypted message.
|
||||
- **NOTE**: If your config does not remove the version number by default, then you should add **--no-emit-version** to avoid giving away version information.
|
||||
- Encrypt a file with a password: `gpg -c <file> -o <output_file>`
|
||||
- Similar to above, you should also add `-a` before `-c` if you want the encrypted output to be in ASCII and not binary.
|
||||
- Decrypt a file and save the results: `gpg -d <file> -o <output_file>`
|
||||
- Decrypt a file and print the contents: `gpg -d <file>`
|
||||
|
||||
**NOTE**: Using a password to encrypt a file is not as secure as using a public key since a password can be easily solved in trivial time.
|
||||
|
||||
## Key Security
|
||||
|
||||
- Backup your private key: `gpg -a --export-secret-keys <user_id> > privkey.asc`
|
||||
- Import a backup of your private key: `gpg --import privkey.asc`
|
||||
|
||||
### Editing your key
|
||||
|
||||
- Open the GPG shell: `gpg --edit-key <user_id>`
|
||||
- `passwd`: Change the passphrase of your GPG key
|
||||
- `clean`: Compact any user ID that is no longer usable (e.g. revoked or expired)
|
||||
- `revkey`: Revoke a key or subkey
|
||||
- `addkey`: Add a subkey to this key
|
||||
- `expire`: Change the key expiration time
|
||||
- `quit`: Close the GPG shell
|
||||
- `save`: Save your changes and quit
|
||||
- `fpr`: Show the key fingerprint
|
||||
|
||||
**NOTE**: To add an email address to your GPG key, use `adduid`. You can set your preferred email address with `primary`.
|
||||
|
||||
### Using Multiple Devices
|
||||
|
||||
If you want to use your GPG key on multiple devices, then you should strip out the master key and only use subkeys on less secure systems.
|
||||
|
||||
1. Get the ID of the subkey you want to export: `gpg -K`
|
||||
2. Export that subkey: `gpg -a --export-secret-subkeys <subkey_id>! > /tmp/subkey.gpg`
|
||||
|
||||
**NOTE**: The `!` after `<subkey_id>` is very important. Without it, all of your subkeys would be exported instead of just the one you specified.
|
||||
|
||||
Now that you have a copy of the subkey, you need to change its password.
|
||||
|
||||
1. Create a temporary import: `gpg --homedir /tmp/gpg --import /tmp/subkey.gpg`
|
||||
2. Edit the key (in its temporary location): `gpg --homedir /tmp/gpg --edit-key <user_id>`
|
||||
- Change the password: `passwd`
|
||||
- Save changes: `save`
|
||||
3. Export the *final* subkey, ready for use on a different device: `gpg --homedir /tmp/gpg -a --export-secret-subkeys <subkey_id>! > /tmp/subkey.alt.gpg`
|
||||
|
||||
### Dealing with subkeys
|
||||
|
||||
**Never** delete your expired or revoked subkeys. This makes it impossible to decrypt files encrypted with the old subkey. **Only** delete expired or revoked keys from other users to clean your keyring.
|
||||
|
||||
Remember to extend your expiration dates. This shows that the key is still active and being used by its holder. A key with no expiration date is not trustworthy.
|
||||
|
||||
You should have a separate subkey for e.g. signing an email message and signing another key. This helps separate the two keys in case one gets compromised.
|
||||
|
||||
## Signing Things
|
||||
|
||||
A GPG signature is used to cerify and timestamp documents and other files. If the file is modified, verification of the signature will fail.
|
||||
|
||||
- Sign a file and compress it: `gpg -s <file> -o <file.sig>`
|
||||
- Note that `-s` is an alias for `--sign`. Use whichever you prefer.
|
||||
- Note that you must specify the output to be a `.sig` file.
|
||||
|
||||
**NOTE**: A signed file is **NOT** encrypted. To encrypt a signed file, use `gpg -R <user_id> -e <file.sig>` on the `.sig` file as usual.
|
||||
|
||||
**NOTE**: If you want to sign something but still have the format readable (e.g. if you want everyone to read the content and be able to confirm that it actually comes from you), then use `--clearsign` instead of `--sign`. Note that `-o` must be passed before `--clearsign` if you use this method.
|
||||
|
||||
### Using a Detached Signature
|
||||
|
||||
A detached signature creates a separate signature file. This allows you to share the signature separately from the document or file itself.
|
||||
|
||||
- Create a detached signature: `gpg --detach-sig <file> -o <file.sig>`
|
||||
- This is the preferred method when distributing software and other critical information where changes to the file would be detrimental.
|
||||
- A detached signature is useful for software, images, and other files that aren't plain text.
|
||||
- This allows the user to verify that a program, file, or other content has not been modified by a third party.
|
||||
|
||||
**NOTE**: If you want to make your signature ASCII readable, be sure to add `-a` when creating it.
|
||||
|
||||
## Verifying Signatures
|
||||
|
||||
How can you make sure that you received the right file or other content? With signatures!
|
||||
|
||||
- Verify a signature: `gpg --verify <sig_file>`
|
||||
- Note that if the contents of the file is not included in the `<sig_file>`, GPG will assume that the file to verify is the file in the same directory without `.sig`.
|
||||
- If for some reason you need to verify a file that doesn't follow this naming convention (should never happen), add the file to verify after `<sig_file>`.
|
||||
|
||||
**NOTE**: If a file has been encrypted and signed (i.e. `file.sig.gpg` and `file.sig.asc`), you should first decrypt the file then verify the signature separately.
|
||||
|
||||
## Encrypting Your Own Files
|
||||
|
||||
- `gpg -e -a -r <user_id> <file>`
|
||||
|
||||
## Revoking a Key
|
||||
|
||||
**NOTE**: Anyone with access to your revocation certificate can revoke your key, rendering it useless. You should only revoke a key if it is compromised, lost, or you forgot your passphrase.
|
||||
|
||||
- Revoking the key: `gpg --import <fingerprint>.rev`
|
||||
- Updating the keyserver: `gpg --keyserver <keyserver> --send-keys <user_id>`
|
283
help/other.md
283
help/other.md
@ -1,283 +0,0 @@
|
||||
This file holds other GNU/Linux information that aren't (?) detailed enough to be their own file.
|
||||
|
||||
## Ranger
|
||||
|
||||
### Movement Keys
|
||||
|
||||
- Scroll down: `j`
|
||||
- Scroll up: `k`
|
||||
- Go back one directory: `h`
|
||||
- Go forward one directory *or* open the selected file: `l`
|
||||
- Move to the top of the file list: `gg`
|
||||
- Move to the bottom of the file list: `G`
|
||||
- Go to the Nth file: `<N>gg`
|
||||
- Go to the home directory: `gh`
|
||||
- Go to the root directory: `gr`
|
||||
- Quit ranger: `q`
|
||||
|
||||
### Useful Things
|
||||
|
||||
- Search for files in the current directory: `/`
|
||||
- Quickly find and automatically open files that match the pattern: `f`
|
||||
- Manually choose software to open the selected file with: `r`
|
||||
- Edit the selected file in your editor of choice: `E`
|
||||
- Switch back to the terminal and cd to the current directory: `S`
|
||||
- Toggle hidden files: `zh`
|
||||
|
||||
### Other Commands
|
||||
|
||||
- Enter command mode: `:`
|
||||
- Change how files are sorted: `o`
|
||||
- Sort by size: `s`
|
||||
- Sort by file type: `t`
|
||||
- Sort by last modified: `m`
|
||||
- Sort by date created: `c`
|
||||
- Sort by time accessed: `a`
|
||||
- Sort alphabetically (default): `b`
|
||||
- Reverse the results: `r`
|
||||
- Randomize the results: `z`
|
||||
- Rename the selected file: `:r <newname>`
|
||||
- Edit an existing filename: `A`
|
||||
|
||||
### Other notes
|
||||
|
||||
- You should never use ranger to manipulate files. Ranger does one thing and does it well: explore files.
|
||||
- You should not use tabs in ranger. What you would do with tabs can be accomplished easier with the terminal.
|
||||
- Although bookmarks are a feature in ranger, your file management should be simple enough that bookmarks aren't required.
|
||||
|
||||
## GNU/Linux Root File Structure
|
||||
|
||||
```
|
||||
/ # Root directory
|
||||
/bin # Binaries for global commands (ls, cat, etc.)
|
||||
/boot # Boot loader files (grub, the linux kernel, etc.)
|
||||
/dev # "Device files" (/dev/null, /dev/random, etc.)
|
||||
/etc # System-wide configuration files
|
||||
/home # Saved files and personal settings of each user
|
||||
/lib # Libraries used by the binaries in /bin
|
||||
/lib64 # 64-bit libraries
|
||||
/mnt # Temporarily mounted filesystems reside here
|
||||
/opt # Applications that don't rely on other dependencies
|
||||
/proc # Provides process and kernel information as files
|
||||
/root # Home directory for the root user
|
||||
/run # Information about the running system since last boot
|
||||
/sbin # System binaries (fsck, init, route, etc.)
|
||||
/srv # Site-specific data served by the system
|
||||
/sys # Contains information about the system
|
||||
/tmp # Temporary files used for processes
|
||||
/usr # Applications that rely on other dependencies
|
||||
/var # Variable files that are supposed to change over time
|
||||
```
|
||||
|
||||
## Waterfox
|
||||
|
||||
### Command Mode
|
||||
|
||||
- Take a screenshot of the entire page `screenshot --fullpage`
|
||||
- Take a screenshot of the visible window only `screenshot`
|
||||
- Restart the browser `restart`
|
||||
|
||||
### Preferences
|
||||
|
||||
Waterfox has 2 preference files: `prefs.js` and `user.js`.
|
||||
|
||||
`prefs.js` are the settings defined by the browser and `user.js` is an optional file that you can create. `user.js` takes precedence over `prefs.js` and will replace the settings in `prefs.js` when Waterfox is started.
|
||||
|
||||
### Theme
|
||||
|
||||
Waterfox allows you to customize the appearance of the browser by creating your own `userChrome.css`. It is located inside of the `chrome` folder, which needs to be created by the user.
|
||||
|
||||
## tty
|
||||
|
||||
### Moving Around
|
||||
|
||||
- Move to the previous terminal: `Alt+Left`
|
||||
- Move to the next terminal: `Alt+Right`
|
||||
- Switch to the Nth terminal: `Ctrl+Alt+F<N>`
|
||||
- Scroll up: `Shift+PgUp`
|
||||
- Scroll down: `Shift+PgDn`
|
||||
|
||||
### Manipulating Text
|
||||
|
||||
- Copy text: `Ctrl+Shift+C`
|
||||
- Paste text: `Ctrl+Shift+V`
|
||||
- Go to the beginning of the line: `Ctrl+A`
|
||||
- Go to the end of the line: `Ctrl+E`
|
||||
- Remove everything after the cursor: `Ctrl+K`
|
||||
- Clear the terminal: `Ctrl+L`
|
||||
|
||||
### Piping
|
||||
|
||||
- Take the output from `a` and use it as the input for `b`: `a | b`
|
||||
- Take the output from `a` and write it to the file `b`: `a > b`
|
||||
- Take the output from `a` and append it to the file `b`: `a >> b`
|
||||
|
||||
### Wildcard
|
||||
|
||||
- Use `*` anywhere as a wildcard to find all matches
|
||||
- Use `**` to wildcard subdirectories (e.g. `~/.config/**/*.cr`)
|
||||
|
||||
### Control Keys
|
||||
|
||||
- Cancel the running command: `Ctrl+C`
|
||||
- Suspend the current process (resume with `fg`): `Ctrl+Z`
|
||||
|
||||
## fish - the friendly interactive shell
|
||||
|
||||
### Passing things around
|
||||
|
||||
- Read input from a file: `command < file.txt`
|
||||
- Write output to a file: `command > file.txt`
|
||||
- Append output to a file: `command >> file.txt`
|
||||
- Write an error to a file: `command ^ file.txt`
|
||||
- Append an error to a file: `command ^^ file.txt`
|
||||
|
||||
### Misc.
|
||||
|
||||
- Pipe the output of a program into another one: `git status | lolcat`
|
||||
- Learn more about a program: `man fish` **OR** `fish -h`
|
||||
- Match any single character except `/` (includes an empty string): `?`
|
||||
- Create a new variable: `set my_var "some_string"`
|
||||
- By convention, exported variables are in `$UPPERCASE` and unexported variables are in `$lowercase`
|
||||
- Create a new exported variable: `set -x MY_VAR "some_string"`
|
||||
- Unset a variable: `set -e my_var`
|
||||
|
||||
### Jobs
|
||||
|
||||
- Start a background job: `ncmpcpp &`
|
||||
- Bring a background job to the foreground: `fg`
|
||||
- Move the current program to the background: `<C-z>`
|
||||
|
||||
Note that your fish config file is located at: `~/.config/fish/config.fish`
|
||||
|
||||
### Functions
|
||||
|
||||
```fish
|
||||
function func
|
||||
# Do something
|
||||
end
|
||||
```
|
||||
|
||||
Note that you should put your functions in `~/.config/fish/functions/function_name.fish`.
|
||||
|
||||
### Aliases
|
||||
|
||||
```fish
|
||||
function ls
|
||||
command exa $argv
|
||||
end
|
||||
```
|
||||
|
||||
```fish
|
||||
alias ls="exa"
|
||||
```
|
||||
|
||||
### Autosuggestions
|
||||
|
||||
- Complete autosuggestions with the right arrow **OR** `<C-f>`.
|
||||
- Complete only the next word with alt right **OR** `<A-f>`.
|
||||
|
||||
- `-c` + The program you want to autocomplete for
|
||||
- `-s` + A shorthand parameter (e.g. `-s o` for `-o`)
|
||||
- `-l` + A longhand parameter (e.g. `-l output` for `--output`)
|
||||
- `-a` + Parameter arguments (e.g. `-a "true false"` if an `--option` can take both `true` and `false` as values)
|
||||
|
||||
See complete --help for more options. Examples in `/usr/share/fish/completions`.
|
||||
|
||||
You can make completions in the terminal, a configuration file, anywhere!
|
||||
|
||||
### Tab Completions
|
||||
|
||||
Use tab for tab completion (as obvious as this may seem, it's really useful!)
|
||||
|
||||
Any completions you make should be in `~/.config/fish/completions/program_name.fish`
|
||||
|
||||
### Command substitution
|
||||
|
||||
- Pass the results of one command as the argument of another command: `echo (ls -al)`
|
||||
|
||||
### Expansions
|
||||
|
||||
- Brace expansion: `echo file.{png,jpg}`, `mv *.{cr,rs} src/`
|
||||
- Variable expansion:
|
||||
- `echo $var # => echo 1 2 3`
|
||||
- `echo "$var" # => echo "1 2 3"`
|
||||
- `set a 1; set b a; echo $$b # => 5`
|
||||
- Index range expansion: `echo (seq 10)[1..5] # => echo 1 2 3 4 5`
|
||||
- Reverse output: `echo (seq 10)[-1..1]`
|
||||
- Home directory expansion: `~`
|
||||
- Process expansion: `%self`
|
||||
|
||||
Note that in fish, variables start at 1, similar to lua et al.
|
||||
|
||||
```fish
|
||||
set my_arr "a" "b" "c"
|
||||
```
|
||||
|
||||
- `$argv` is the array of arguments given to the shell or function
|
||||
|
||||
You can change the colors fish uses with `$fish_color_*` and `$fish_pager_color_*`
|
||||
|
||||
To work with multiple lines in fish, either use `Enter` with a block statement (`if`, `for`, `begin`, etc.), use `<A-CR>`, or add `\` to the end of your lines.
|
||||
|
||||
- Only run with a login shell: `status --is-login`
|
||||
- Only run with an interactive shell: `status --is-interactive`
|
||||
- Get the status of the last executed command (success, failure, etc.): `echo $status`
|
||||
|
||||
- Use multiple commands on the same line `;`
|
||||
- And operator: `; and`
|
||||
- Or operator: `; or`
|
||||
|
||||
### Conditionals
|
||||
|
||||
```fish
|
||||
if condition
|
||||
# Do something
|
||||
else
|
||||
# Do something else
|
||||
end
|
||||
```
|
||||
|
||||
### Switch
|
||||
|
||||
```fish
|
||||
switch(name)
|
||||
case Sally
|
||||
# Do something
|
||||
case John
|
||||
# Do something else
|
||||
case '*'
|
||||
# Catch-all
|
||||
end
|
||||
```
|
||||
|
||||
List all the functions available to fish: `functions`
|
||||
|
||||
### Loops
|
||||
|
||||
```fish
|
||||
while true
|
||||
# Do something
|
||||
end
|
||||
```
|
||||
|
||||
```fish
|
||||
for file in *.txt
|
||||
# Do something with all .txt files
|
||||
end
|
||||
```
|
||||
|
||||
```fish
|
||||
for i in (seq 5)
|
||||
# Do something 5 times
|
||||
end
|
||||
```
|
||||
|
||||
Set colors in fish:
|
||||
|
||||
```fish
|
||||
set_color purple
|
||||
echo "some text"
|
||||
set_color normal
|
||||
echo "more text"
|
||||
```
|
@ -1,268 +0,0 @@
|
||||
# Profanity
|
||||
|
||||
- Show basic help information: `/help`
|
||||
- Show all commands: `/help commands`
|
||||
- Show more information about a specific command: `/help <command>`
|
||||
|
||||
## Window Navigation
|
||||
|
||||
- Go to the next window: `Alt-right`
|
||||
- Go to the previous window: `Alt-left`
|
||||
- Go to a specific window: `Alt-<number>` **OR** `/win <number>`
|
||||
- Go to a specific window based on chat name: `/win <room@server.url>` **OR** `/win <person_to_chat_with>`
|
||||
- View the details of all active windows: `/wins`
|
||||
- Change the window numbers so there are no gaps inbetween: `/wins tidy`
|
||||
- Close the current window: `/close`
|
||||
|
||||
## Common Commands
|
||||
|
||||
- Connect to an XMPP server: `/connect user@server.url`
|
||||
- Open a new window and send a message to anyone in the world: `/msg <username@server.url> <message>`
|
||||
- If you just want to open a new window without sending a message, simply omit the `<message>` part of the command
|
||||
- Open a new window and send a message to someone in your contacts list: `/msg <contact> <message>`
|
||||
- Join a chat room: `/join <room@server.url>`
|
||||
- Note that your nickname is by default the username you use for the XMPP server you use (`username@server.url`)
|
||||
- To specifiy a different nickname when joining a room, use `/join <room@server.url> nick <name>`
|
||||
- If the room is located at `room@conference.server.url`, you can simply use `/join <room>`
|
||||
- If a room requires a password, add `password <password>` to the end of the command
|
||||
- Change your nickname in a chat room: `/nick <name>`
|
||||
- Send a file to the chat: `/sendfile <filepath>`
|
||||
- Note that it may be better to just upload the file somewhere
|
||||
- Leave a chat room: `/leave`
|
||||
- Logout of the current XMPP server: `/disconnect`
|
||||
- Quit profanity: `/quit`
|
||||
|
||||
### Working with Contacts
|
||||
|
||||
- Add someone to your list of contacts: `/roster add <username@server.url>`
|
||||
- To specify a nickname for the contact you add, simply add `<nickname>` to the end of the command
|
||||
- Note that by convention the nickname should not contain spaces
|
||||
- Request to know when someone is online or offline: `/sub request <username@server.url>`
|
||||
- Note that the official term for this is "subscribing to a contact's presence"
|
||||
- To remove someone from your list of contacts: `/sub remove <username@server.url>`
|
||||
- Note that this also removes your subscription to their presence, and their subscription to yours
|
||||
- Approve a contact's request to know when you're online or offline: `/sub allow <username@server.url`
|
||||
- To deny a request: `/sub deny <username@server.url`
|
||||
- List all of the sub requests you have sent that are waiting for approval: `/sub sent`
|
||||
- List all the sub requests that you have received but not yet approved or denied: `/sub received`
|
||||
- Invite a contact to the current chat room: `/invite <contact>`
|
||||
- You can add a `<message>` at the end to specify a reason for them to join
|
||||
- Note that, like other commands, you must put the contact name in quotations if it contains spaces (avoid doing this)
|
||||
- To show all the rooms that you have been invited to (and haven't accepted or declined yet), use `/invites`
|
||||
- View all your contacts: `/roster`
|
||||
- Remove a nickname from a contact: `/roster clearnick <username@server.url>`
|
||||
|
||||
Note that if you're already in a chat window with the user, you can use the `/sub` commands without specifying the user.
|
||||
|
||||
### Contact Groups
|
||||
|
||||
- List all the current groups: `/group`
|
||||
- Show contacts in a particular group: `/group show <group_name>`
|
||||
- The group name can be, for example, `friends`, `family`, or even more specific like `project` or `service`.
|
||||
- Add a contact to a group: `/group add <group_name> <contact>`
|
||||
- Note that there is no command to add a group
|
||||
- Adding a contact to a group that doesn't exist will create it
|
||||
- Remove a contact from a group: `/group remove <group_name> <contact>`
|
||||
|
||||
### Presence (aka status)
|
||||
|
||||
- Set your status to away: `/away`
|
||||
- Set your status to extended away: `/xa`
|
||||
- Set your status to available for chat: `/chat`
|
||||
- Set your status to online: `/online`
|
||||
- Set your status to do not disturb: `/dnd`
|
||||
|
||||
**NOTE**: Each of these commands accept an optional `<message>`.
|
||||
|
||||
- Get the status of a user: `/status <contact|nick>`
|
||||
|
||||
## Direct Messages
|
||||
|
||||
- To direct a message towards a specific person, type the name of the person you want to direct the message to then press tab for Profanity to autocomplete it
|
||||
- To start a private chat session with someone in the chat room, use `/msg <nickname> <message>`
|
||||
|
||||
### Off The Record Messaging
|
||||
|
||||
**Do this first:** Generate a private key for the account you're using: `/otr gen`
|
||||
|
||||
- Start a new conversation using OTR: `/otr start <username@server.url>`
|
||||
- Start sending encrypted messages in an existing conversation window: `/otr start`
|
||||
|
||||
At this point, the conversation is encrypted with OTR, but the contact has not yet been authenticated.
|
||||
|
||||
#### Question and Answer
|
||||
|
||||
**To verify that a recipient is really who they say they are** you need to ask the contact a question that *only they would know* with an expected answer.
|
||||
|
||||
- Ask a question to verify that the recipient is really who they say they are: `/otr question "<question_that_only_they_could_answer>" "<answer>"`
|
||||
- If the recipient answers correctly, the OTR session becomes trusted, otherwise the authentication will fail and the OTR session is untrusted
|
||||
- To answer a question sent to you, use: `/otr answer "<answer>"`
|
||||
|
||||
**You should always authenticate both ways.** That is, after Bob verifies that Alice is really who she says she is, Alice needs to verify that Bob is really who he says he is. More specifically, each contact will send a question to the other contact.
|
||||
|
||||
#### Shared Secret
|
||||
|
||||
Another way to verify that a recipient is **really who they say they are**, you can use a shared "secret" (aka passphrase) that only you and the recipient know.
|
||||
|
||||
- Authenticate with a shared secret: `/otr secret <passphrase>`
|
||||
- Note that both parties must enter the same secret before both parties are authenticated
|
||||
|
||||
#### Fingerprint
|
||||
|
||||
The final way to verify that a recipient is who they say they are is manually with their key's fingerprint.
|
||||
|
||||
**You must exchange fingerprints with your contact via another secure communication channel**, preferrably in person.
|
||||
|
||||
- Display your key's fingerprint: `/otr myfp`
|
||||
- View the fingerprint of a recipient whilst in an OTR session: `/otr theirfp`
|
||||
- When you verify someone, this fingerprint should match the one that they gave you in real life (or, arguably less secure, on another communication channel considered secure).
|
||||
- Manually authenticate the recipient: `/otr trust`
|
||||
- You should only manually verify a recipient **if and only if** the fingerprints match.
|
||||
- Note that you can untrust the recipient at any time with `/otr untrust`
|
||||
|
||||
**NOTE**: You can only use off the record messaging with other people that have it enabled.
|
||||
|
||||
#### OTR Options
|
||||
|
||||
The default settings in Profanity allow for unencrypted messages. OTR must be started manually with `/otr start`.
|
||||
|
||||
You have the option to change this setting to force an encrypted conversation.
|
||||
|
||||
- Allow unencrypted messages, OTR must be started manually: `/otr policy manual`
|
||||
- Attempt to start an OTR session by default (both parties must have a policy set to `opportunistic` or `always`): `/otr policy opportunistic`
|
||||
- Always use encrypted messages (unencrypted messages will not be sent): `/otr policy always`
|
||||
- View the current policy for OTR: `/prefs otr`
|
||||
- To use OTR always for a specific account: `/account set <account_name> otr always`
|
||||
- To show all the settings for a specific account: `/account show <account_name>`
|
||||
- To always use OTR for a particular contact: `/otr policy always <contact>`
|
||||
- Show the current settings for a particular contact: `/account show <contact>`
|
||||
|
||||
#### Logging
|
||||
|
||||
- Log OTR messages in plaintext: `/otr log on`
|
||||
- Log redacted messages: `/otr log redact`
|
||||
- Do not log OTR messages: `/otr log off`
|
||||
- Show the current log file location: `/log where`
|
||||
|
||||
**NOTE**: Messages will only be logged if `/chlog` is set to `on`. Use `/chlog on|off` to turn chat logging on or off respectfully.
|
||||
|
||||
### GPG Encrypted Messaging
|
||||
|
||||
**NOTE**: Although the default command is `/pgp`, the config file makes `/gpg` work as well.
|
||||
|
||||
- List all the keys on your system: `/pgp keys`
|
||||
- Assign a GPG key to your account (required for other contacts to send GPG-encrypted messages to you): `/account set <your_account@server.url> pgpkeyid <your_pgpkeyid>`
|
||||
- Manually assign a GPG key to a contact: `/pgp setkey <their_account@server.url> <their_pgpkeyid>`
|
||||
- List all currently known public keys (both received through signed presence and set manually): `/pgp contacts`
|
||||
|
||||
- Sending GPG-encrypted messages: `/pgp start <user@server.url>`
|
||||
- Note that if you're already in the conversation window, the last part isn't needed
|
||||
- Stop sending GPG-encrypted messages: `/pgp end`
|
||||
- Unlike OTR, GPG encryption is one-way. That is, it is possible for you to send encrypted messages and not the recipient. Ensure that both you (`send`) and the other party (`recv`) are sending encrypted messages
|
||||
|
||||
Note that GPG message logging works the same way as OTR, except with `/pgp log` instead of `/otr log`
|
||||
|
||||
**NOTE**: Both parties must have GPG encryption enabled for this to work.
|
||||
|
||||
To change the message symbol used for OTR and GPG (by default `~` for both), use `/otr char <symbol>` and `/pgp char <symbol>` respectfully.
|
||||
|
||||
## Other Commands
|
||||
|
||||
- Change the affiliation of a user in a room: `/affiliation set <affiliation> <user@server.url> [<reason>]`
|
||||
- To list all affiliations (or a specific one), use `/affiliation list [<affiliation>]`
|
||||
- Note that an affiliation may be either `owner`, `admin`, `member`, `outcast`, or `none`.
|
||||
- Change the role of a user in the room: `/role set <role> <nick> [<reason>]`
|
||||
- To list all roles (or a specific one), use `/role list [<role>]`
|
||||
- A role may be either `moderator`, `participant`, `visitor`, or `none`.
|
||||
- Automatically connect to a particular account on startup: `/autoconnect set <user@server.url>`
|
||||
- To turn off autoconnect: `/autoconnect off`
|
||||
- Kick a user from a chat room: `/kick <user@server.url> [<reason>]`
|
||||
- Ban a user from a chat room: `/ban <user@server.url> [<reason>]`
|
||||
- Show all the clients that a user uses: `/caps <user@server.url>`
|
||||
- If you're in a conversation with that user, the last part isn't needed
|
||||
- Clear the current window: `/clear`
|
||||
- Export contacts to a csv file: `/export ~/contacts.csv`
|
||||
- Enable or disable logging for a chat room (not personal messages): `/grlog on|off`
|
||||
- Show information about a contact, room, or room member: `/info <contact>`
|
||||
- Ping an XMPP server: `/ping <server.url>`
|
||||
- If `<server.url>` is not supplied, your chat server will be pinged by default
|
||||
- Show all preferences: `/prefs`
|
||||
- Enable or disable the splash screen: `/splash on|off`
|
||||
- Set the status bar text (can also be used for time): `/time statusbar set <text>`
|
||||
|
||||
### Aliases
|
||||
|
||||
- Add an alias: `/alias add <name> <value>`
|
||||
- Remove an alias: `/alias remove <name>`
|
||||
- List all aliases: `/alias list`
|
||||
|
||||
### Blocked Users
|
||||
|
||||
- Add a blocked user: `/blocked add <user@server.url>`
|
||||
- Remove a blocked user: `/blocked remove <user@server.url>`
|
||||
- List all blocked users: `/blocked`
|
||||
|
||||
### Bookmarks
|
||||
|
||||
Bookmarks allow you to easily join rooms that you save.
|
||||
|
||||
- List all bookmarks: `/bookmark list`
|
||||
- Add a bookmark: `/bookmark add <room>`
|
||||
- Add `nick <nick>` to use a specific nickname
|
||||
- Add `password <password>` to specify a room password
|
||||
- Add `autojoin <on|off>` to automatically join the room
|
||||
- Update an existing bookmark: `/bookmark update <room> <things_to_change>`
|
||||
- Remove a bookmark: `/bookmark remove <room>`
|
||||
- Join a bookmarked room: `/bookmark join <room>`
|
||||
|
||||
### Working with Occupants
|
||||
|
||||
- Show the occupants panel in the current room: `/occupants show`
|
||||
- Hide the occupants panel in the current room: `/occupants hide`
|
||||
- Show user ids in the occupants panel: `/occupants show|hide jid`
|
||||
- Change the size of the occupants panel: `/occupants size <percent>`
|
||||
- Note that percent should be a value between 1 and 99
|
||||
- Group the occupants panel by role: `/privileges on|off`
|
||||
|
||||
### Real-time Notifications
|
||||
|
||||
- Show when a contact is typing (on by default): `/intype on|off`
|
||||
- Send typing notifications to others (off by default): `/outtype on|off`
|
||||
- Show when a message has been received: `/receipts request on|off`
|
||||
- Let others know when you've read a message (by sending a receipt): `/receipts send on|off`
|
||||
- Send chat state notifications such as typing, paused, active, and gone (defaults to off): `/states on|off`
|
||||
|
||||
Note that receipts are off by default (since they do affect privacy quite a bit).
|
||||
|
||||
### Other Room Commands
|
||||
|
||||
- Accept the default room configuration: `/room accept`
|
||||
- Reject the default room configuration and destroy the room: `/room destroy`
|
||||
- Edit the room configuration: `/room config`
|
||||
- List all the chat rooms available to a specific XMPP server: `/rooms [<service>]`
|
||||
- Set the room subject: `/subject set <subject>`
|
||||
- Clear the room subject: `/subject clear`
|
||||
- Edit the current room subject (use tab completion to auto-display the subject): `/subject edit <subject>`
|
||||
- Prepend text to the subject: `/subject prepend <text>`
|
||||
- Append text to the subject: `/subject append <text>`
|
||||
|
||||
### Roster Panel
|
||||
|
||||
- Show the roster panel: `/roster show`
|
||||
- Hide the roster panel: `/roster hide`
|
||||
- Print all online contacts to the console: `/roster`
|
||||
|
||||
### Themes
|
||||
|
||||
- List all themes: `/theme list`
|
||||
- Load a specific theme: `/theme load <theme>`
|
||||
- Show all available colors from the terminal: `/color`
|
||||
- Show the color settings for the current theme: `/theme properties`
|
||||
|
||||
### Who
|
||||
|
||||
- Show contacts or room occupants with a specified presence: `/who <online|offline|away|dnd|xa|chat>`
|
||||
- Note that you can specify a `<group>` to the end of this command to get, for example, everyone online in the friends group
|
||||
- Show room occupants with a specific role: `/who moderator|participant|visitor`
|
||||
- Show room occupants with a specific affiliation: `/who owner|admin|member`
|
||||
|
383
help/vim.md
383
help/vim.md
@ -1,383 +0,0 @@
|
||||
[Vim is a language](https://github.com/mhinz/vim-galore). Use it often enough and you'll be [fluent](https://medium.com/@mkozlows/why-atom-cant-replace-vim-433852f4b4d1) in no time.
|
||||
|
||||
Note that the commands I mention in this file are the ones I use the most often and are by no means exhaustive.
|
||||
|
||||
For some vim commands, I use a `<leader>` keybinding as an alternative since I find it faster. Some of those commands may not be mentioned here. Please see `.vimrc` for more details.
|
||||
|
||||
## Starting vim
|
||||
|
||||
- Open a file at a specific line number: `vim +<number> <file>`
|
||||
- Open multiple files in separate tabs: `vim -p <files>`
|
||||
- Open all files that contain the function / variable / string `str` in the current directory: `vim -p "grep -l <str> [files]"`
|
||||
- Note that `[files]` is optional, allowing you to only search for e.g. `*.js` files
|
||||
- Also note that you should use "\`" instead of quotation marks
|
||||
- Compare two files side by side for differences between the two: `vim -d <file1> <file2>`
|
||||
|
||||
## Working with Tab Characters
|
||||
|
||||
- Convert tabs to spaces: `:retab`
|
||||
- Reindent the entire file: `gg=G`
|
||||
- `gg` to go to the top of the file
|
||||
- `=G` to reindent until the bottom of the file
|
||||
|
||||
## Movement Keys
|
||||
|
||||
- Go to the beginning of the file: `gg`
|
||||
- Go to the end of the file: `G`
|
||||
- Go to the beginning of the line: `0`
|
||||
- Go to the first non-whitespace character: `^`
|
||||
- Go to the end of the line: `$`
|
||||
- Go to the next word: `w`
|
||||
- Go to the next big word: `W`
|
||||
- Go to the previous word: `b`
|
||||
- Go to the previous big word: `B`
|
||||
- Go to the next end of a word: `e`
|
||||
- Go to the next end of a big word: `E`
|
||||
- Go to the previous sentence: `(`
|
||||
- Go to the previous paragraph: `{`
|
||||
- Go to the next sentence: `)`
|
||||
- Go to the next paragraph: `}`
|
||||
|
||||
Note that `0` is sometimes called the **hard beginning of line** and `^` is sometimes called the **soft beginning of line**.
|
||||
|
||||
Note that you can also go to a specific line number with `5gg` or `5G`, but you should really be using other keys like `/` instead.
|
||||
|
||||
- Go to the previous line: `k`
|
||||
- Go to the next line: `j`
|
||||
- Go to the previous letter: `h`
|
||||
- Go to the next letter: `l`
|
||||
|
||||
Note that a letter in vim refers to the characters in the file.
|
||||
|
||||
These keys may also be used similar to movement keys, although you should really be using the other keys instead.
|
||||
|
||||
Note that you can chain numbers with the movement keys, such as `5j` to move down 5 lines, although you should really be using the other keys instead.
|
||||
|
||||
Note that you should avoid mapping `j` to `gj` (same for `k` to `gk`). It encourages bad practice and defeats the purpose of using vim.
|
||||
|
||||
- Go to the next instance of `<KEY>` on the current line: `f + <KEY>`
|
||||
- Go to the previous instance of `<KEY>` on the current line: `F + <KEY>`
|
||||
- Go until just before the next instance of `<KEY>` on the current line: `t + <KEY>`
|
||||
- Go until just before the previous instance of `<KEY>` on the current line: `T + <KEY>`
|
||||
|
||||
You can easily move through instances like so:
|
||||
|
||||
- Go to the next instance when using `f` or `t`: `;`
|
||||
- Go to the previous instance when using `f` or `t`: `,`
|
||||
|
||||
Note that these keys get rarely used (if ever). TODO: Consider aliasing them to something else instead.
|
||||
|
||||
### Searching for Things
|
||||
|
||||
Note that the search commands are also considered movement keys. You can chain them with the operator commands like everything else.
|
||||
|
||||
- Search for the next instance of a string: `/string`
|
||||
- Search for the previous instance of a string: `?string`
|
||||
- Search for the next occurrence of the word under the cursor: `*`
|
||||
- Search for the previous occurrence of the word under the cursor: `#`
|
||||
|
||||
TODO: It may be easier to make an alias for `*` and `#`
|
||||
|
||||
Once you are back in normal mode, you can navigate through search results like so:
|
||||
|
||||
- Go to the next search result: `n`
|
||||
- Go to the previous search result: `N`
|
||||
|
||||
## Mapping Things
|
||||
|
||||
Note that the commands below assume that you're writing them in a `.vimrc`. If you want to add new mappings directly in vim, remember to execute the commands in command mode with `:`.
|
||||
|
||||
- Map in normal, visual, and operator-pending mode: `map`
|
||||
- Map in normal mode only: `nmap`
|
||||
- Map in visual mode only: `xmap`
|
||||
- Map in command mode only: `cmap`
|
||||
- Map in operator-pending mode only: `omap`
|
||||
- Map in insert mode only: `imap`
|
||||
|
||||
Note that you should be using `noremap` instead of `map` most (if not all) of the time. This prevents mappings from using mappings made by other commands.
|
||||
|
||||
## Chained (Operator) Commands
|
||||
|
||||
- Copying things: `y + <MOTION>`
|
||||
- Copy the current line: `yy`
|
||||
- Copy the next 5 lines: `y5y`
|
||||
- Copy the current word: `yw`
|
||||
- Copy to the end of the line: `y$`
|
||||
- Copy inside of the tag: `yit`
|
||||
- Copy all of the tag: `yat`
|
||||
- Deleting things: `d + <MOTION>`
|
||||
- Delete the current line: `dd`
|
||||
- Delete the current word: `dw`
|
||||
- Delete the next 5 words: `d5w`
|
||||
- Delete up to the period: `dt.`
|
||||
- Delete up to and including the period: `df.`
|
||||
- Delete inside of the square brackets: `di[`
|
||||
- Delete all of the curly braces: `da{`
|
||||
- Changing things: `c + <MOTION>`
|
||||
- Change the current line: `cc`
|
||||
- Change the current word: `cw`
|
||||
- Change the next 5 words: `c5w`
|
||||
- Change the next 5 letters: `c5l`
|
||||
- Change inside the quotation marks: `ci"`
|
||||
- Change all of the parentheses: `ca(`
|
||||
- Change up until the question mark: `ct?`
|
||||
- Change up to and including the question mark: `cf?`
|
||||
|
||||
`c` is functionally similar to `d`, but also leaves you in insert mode to change things.
|
||||
|
||||
Note that `ci<block>` and `ca<block>` work for pretty much anything, including `{`, `[`, and `t` (for `<tags>`).
|
||||
|
||||
Note that text deleted is also copied into vim's hidden buffer. There is no need for a "cut" command since copying things is handled automatically by vim.
|
||||
|
||||
**NOTE**: If you want to copy all lines in a file to the clipboard, use: `:%y+`
|
||||
|
||||
Repeat the last operation with `.`. This is really powerful when you want to perform the same action multiple times.
|
||||
|
||||
If you want to repeat the last operation on multiple lines, simply press `<C-v>` to enter visual block mode, select the lines you want to operate on, then execute `.` on them.
|
||||
|
||||
## Basic Commands
|
||||
|
||||
- Undo the last action: `u`
|
||||
- Redo the last action: `<C-r>`
|
||||
- Paste below the current line: `p`
|
||||
- Paste above the current line: `P`
|
||||
- Delete the current character: `x`
|
||||
- Backspace from the cursor position: `X`
|
||||
|
||||
Note: If you only copied part of a line, then `p` and `P` will paste after and before the cursor respectfully.
|
||||
|
||||
Note that if you want to paste from the system clipboard (i.e. not vim), then you must use `<C-S-v>` in insert mode.
|
||||
|
||||
## Inserting Things
|
||||
|
||||
- Insert before the cursor: `i`
|
||||
- Insert at the beginning of the line: `I`
|
||||
- Insert after the cursor: `a`
|
||||
- Insert at the end of the line: `A`
|
||||
- Insert below the current line: `o`
|
||||
- Insert above the current line: `O`
|
||||
- Replace the character under the cursor: `r`
|
||||
- Enter replace mode, replacing the characters you type over: `R`
|
||||
|
||||
To help remembering `a`, just know that it *appends* things (after the cursor and at the end of the line)
|
||||
|
||||
An example of combining the insert keys with movement keys is `ea`. This combination of keys allows you to append text to the end of a word, since `e` goes to the end of the word and `a` enters insert mode after the cursor.
|
||||
|
||||
Note that you can use `<C-o>` at any time while in insert mode to execute a single normal mode command. This is useful if, for example, you want to navigate to the end of the line after making changes to another part of it.
|
||||
|
||||
## Working with Files
|
||||
|
||||
Note that there are a lot of buffer commands, however, I only document the ones I actively use here.
|
||||
|
||||
- Switch to the next window: `<C-w>w`
|
||||
- Switch to a specific window: `<C-w><h/j/k/l>`
|
||||
- Move a window up *or* to the left: `<C-w>R`
|
||||
- Move a window down *or* to the right: `<C-w>r`
|
||||
- Move the current window to a specific side: `<C-w><H/J/K/L>`
|
||||
|
||||
Also note that vim tabs is a thing, although you really shouldn't be using them.
|
||||
|
||||
- List all the buffers: `:ls`
|
||||
- Search all your buffers for one with a specific pattern in its name and go to it: `:b pattern`
|
||||
- Go to the next buffer: `:bn`
|
||||
- Go to the previous buffer: `:bp`
|
||||
- Delete the current buffer: `:bd`
|
||||
- Open the previously viewed buffer: `:b#`
|
||||
- Open a new buffer with a given file: `:e <filename>`
|
||||
- Open the file under the cursor: `gf`
|
||||
|
||||
TODO: Replace these commands with the ones from your plugins
|
||||
|
||||
- Open a horizontal split: `:sp [filename]`
|
||||
- Open a vertical split: `:vs [filename]`
|
||||
- Open a new tab: `:tabnew [filename]`
|
||||
- Switch to the next tab: `gt`
|
||||
- Switch to the previous tab: `gT`
|
||||
- Close all windows except the current one: `:only`
|
||||
- Close all tabs except the current one: `:tabonly`
|
||||
|
||||
## Search and Replace
|
||||
|
||||
- Replace foo with bar everywhere: `:%s/foo/bar/g`
|
||||
- Replace foo with bar on the current line only: `:s/foo/bar/g`
|
||||
- Replace foo with bar everywhere, but ask for confirmation on each change: `:%s/foo/bar/gc`
|
||||
- Change the current item and move on to the next one: `y`
|
||||
- Do not change the current item and move on to the next one: `n`
|
||||
- Change all the results: `a`
|
||||
- Quit making changes: `q`
|
||||
|
||||
By default searches are assumed to be case insensitive if the entire string is lowercase. Note that if case matters and the entire search string is lowercase, you should chain `I` to the command to make it case sensitive.
|
||||
|
||||
## Visual Mode
|
||||
|
||||
Note that you will never need to use visual mode 99.9% of the time. Use the other keys instead.
|
||||
|
||||
- Enter visual mode: `v`
|
||||
- Enter linewise visual mode: `V`
|
||||
- Switch sides (in order to mark in the other direction): `o`
|
||||
|
||||
Visual mode can be combined with commands such as `y`, `>`, and `d` (non-exaustive).
|
||||
|
||||
## Other Stuff
|
||||
|
||||
Note that commands I do not find useful are not mentioned here. Consult the help files if you really want to know all the commands in vim.
|
||||
|
||||
- Move the current line to the middle of the screen: `zz`
|
||||
- Move the current line to the top of the screen: `zt`
|
||||
- Move the screen down half a page: `<C-d>`
|
||||
- Move the screen up half a page: `<C-u>`
|
||||
- Convert to lowercase: `gu + <MOTION>`
|
||||
- Convert to uppercase: `gU + <MOTION>`
|
||||
- Jump between the opening and closing parentheses, brackets, curly braces, and tags: `%`
|
||||
- Delete the character under the cursor and enter insert mode: `s`
|
||||
- Note that this is an alias of `xi`
|
||||
- Clear the current line and enter insert mode: `S`
|
||||
- Note that this is an alias of `cc`
|
||||
- Join the current line with the next one: `J`
|
||||
- Prepend or append the same text to multiple lines: `<C-v><MOTION>I` **OR** `<C-v><MOTION>A`
|
||||
|
||||
## Macros
|
||||
|
||||
Macros are used for complex commands that can't be repeated with `.`. They help reduce repetition and repeat exactly what you did when you create them.
|
||||
|
||||
- Start recording a macro: `q + <SYMBOL>`
|
||||
- To end the macro, press `q` again.
|
||||
- If you want to end the macro in insert mode, press `<C-o>` then `q`.
|
||||
- Play back a previously recorded macro: `@ + <SYMBOL>`
|
||||
- To repeat the last macro played, simply use `@@`.
|
||||
- Repeat a macro on all lines: `:%norm! @<SYMBOL>`
|
||||
- To repeat a macro on only a specific set of lines, use: `:<from>,<to>norm! @<SYMBOL>`
|
||||
- From line 5 to the end of the file: `:5,$norm! @<SYMBOL>`
|
||||
- Repeat a macro on all lines matching a pattern: `:g/pattern/norm! @<SYMBOOL>`
|
||||
- Delete all lines that contain a pattern: `:g/pattern/d`
|
||||
- To catch multiple patterns, separate them with `\|`. Example: `:g/pattern_one\|pattern_two/d`
|
||||
- To delete all lines that do NOT contain a pattern, use: `:v/pattern/d`
|
||||
|
||||
## Marking Things
|
||||
|
||||
- Mark the current line: `m + <SYMBOL>`
|
||||
- Go to a previously marked line: `' + <SYMBOL>'`
|
||||
- Go to a previously marked line, exactly where you were before: ``` + <SYMBOL>``
|
||||
- Jump to the previous cursor position: `''`
|
||||
- Jump to the previous cursor position, exactly where you were before: `` ` `` + `` ` ``
|
||||
- Jump to the previous edit location: `g;`
|
||||
- Jump to the next edit location: `g,`
|
||||
|
||||
## Indenting Things
|
||||
|
||||
- Indent: `> + <MOTION>`
|
||||
- Outdent: `< + <MOTION>`
|
||||
|
||||
- Indent the current line: `>>`
|
||||
- Indent the next 10 lines: `10>>`
|
||||
- Outdent the current line: `<<`
|
||||
- Outdent the next 10 lines: `10<<`
|
||||
- Re-indent the entire file: `gg=G`
|
||||
- `gg`: Go to the top of the file
|
||||
- `=`: Start indenting
|
||||
- `G`: Until the end of the file
|
||||
|
||||
Note that all other vim movements work while indenting things as well.
|
||||
|
||||
## Commands
|
||||
|
||||
### Manipulating Files
|
||||
|
||||
- Save the current buffer: `:w`
|
||||
- Chain `q` to save the current buffer then quit it
|
||||
- Chain `!` to force write the current buffer
|
||||
- Quit the current buffer without trying to save: `:q`
|
||||
- Chain `!` to force close the current buffer without saving it
|
||||
- Insert the contents of a file into the current buffer: `:r <filename>`
|
||||
- Insert the results of a shell command into the current buffer: `:r! <command>`
|
||||
- Save the current buffer as a new file: `:saveas <filename>`
|
||||
- Create a new file and open it in a new buffer (not saved until you save it): `:new <filename>`
|
||||
- Reload the current file: `:e`
|
||||
|
||||
### Syntax Highlighting
|
||||
|
||||
- Change the syntax highlighting of the current file: `:set syntax=<syntax>`
|
||||
- Get the syntax of the current file: `:set syntax?`
|
||||
- Note that to get the value of any variable, just add `?` to it.
|
||||
- It is possible to manually change the syntax of a file, although you shouldn't do this since plugins and other features you may have will not be loaded.
|
||||
|
||||
### Spell Check
|
||||
|
||||
- Toggle spell check: `:set spell!`
|
||||
- Jump to the next occurrence of a misspelled word: `]s`
|
||||
- Jump to the previous occurrence of a misspelled word: `[s`
|
||||
- Choose the first suggestion for the word under the cursor: `1z=`
|
||||
- Add the word under the cursor to your personal dictionary: `zg`
|
||||
- Remove the word under the cursor from your personal dictionary: `zug`
|
||||
- Mark the word under the cursor as misspelled: `zw`
|
||||
|
||||
Note that there are more spell check commands out there, although you really shouldn't need them.
|
||||
|
||||
### Commenting lines
|
||||
|
||||
- Comment the current line:
|
||||
- Simply press `I` to enter insert mode at the beginning of the line. From there you can do whatever you want, including inserting a comment.
|
||||
- If you want to repeat the process for multiple lines, you can go to the line you want to change and press `.` to execute the last set of key combinations.
|
||||
- Comment multiple lines at the same time:
|
||||
- Use `<C-v>` to enter visual block mode
|
||||
- Select the lines you want to comment out with `j/k`
|
||||
- Press `I` to go to the beginning of the line
|
||||
- Type whatever you want to put at the beginning of all the lines here, including comments
|
||||
- When you're done, exit the mode as usual
|
||||
|
||||
### Uncommenting lines
|
||||
|
||||
- Uncomment the current line:
|
||||
- Simply press `0` to go to the beginning of the line (if needed)
|
||||
- Then, press `x` to delete the character under the cursor
|
||||
- Uncomment multiple lines at the same time:
|
||||
- Use `<C-v>` to enter visual block mode
|
||||
- Select the lines you want to comment out with `j/k`
|
||||
- Press `x` to delete the first character, repeatedly if necessary
|
||||
- Exit the mode as usual
|
||||
|
||||
## Other Commands
|
||||
|
||||
These commands may get used from time to time, but aren't used enough to warrant keybindings.
|
||||
|
||||
- Switch between soft and hard tabs: `:set expandtab!`
|
||||
- Note that you should never have to use this since the repository should have an `.editorconfig`
|
||||
- Toggle wrap: `:set wrap!`
|
||||
- Most of the time you don't want to hide text in a text editor, especially vim
|
||||
- Resize windows placed on top of each other (as opposed to side by side): `:<N>winc <+/-/=>`
|
||||
- `N` is the number of units to increment / decrement the window size by.
|
||||
- Do not use `N` when using `=`.
|
||||
- Most of the time you shouldn't have to deal with these kinds of window sizes. Instead, prefer vertical splits and `<C-w> + >` / `<C-w> + <` / `<C-w> + =`
|
||||
|
||||
## Plugin Specific
|
||||
|
||||
### fzf.vim
|
||||
|
||||
- Open the result in a new tab: `<C-t>`
|
||||
- Open the result in a new horizontal split: `<C-x>`
|
||||
- Open the result in a new vertical split: `<C-v>`
|
||||
- Use a command in fullscreen: `:Command!`
|
||||
|
||||
### vimtex
|
||||
|
||||
- Change inside the command: `cic`
|
||||
- Change inside the environment: `cie`
|
||||
- Change inside the math block: `ci$`
|
||||
- Change inside the section: `ciP`
|
||||
- Go to the matching pair: `%`
|
||||
- Go to the next section: `]]`
|
||||
- Go to the previous section: `[[`
|
||||
|
||||
## Important Things to Note
|
||||
|
||||
- You should only be in insert mode when you are inserting text. If you are not inserting text, then you should not be in insert mode.
|
||||
- To cancel most things and switch back to normal (keybindings) mode, simply press `esc`.
|
||||
- Line numbers should NOT be important in your daily workflow and should be disabled most of the time. This lets you focus on what you need to look at: the program itself and nothing more.
|
||||
- Registers keep track of all the things that vim has copied, although I haven't found myself using it often enough to document it here.
|
||||
- The leader key (space) is used for commands not specific to any file type.
|
||||
- The local leader (backslash) is used for commands that only affect a certain file type.
|
||||
- Note that vim has folding capabilities as well although I personally haven't made much use of them.
|
||||
|
||||
## Miscellaneous
|
||||
|
||||
- If for some reason you need to edit files that have line feeds in them, you can use `:%s/^M/\r/g` to remove the line feeds. At this point, you should easily be able to tell what this command does and reproduce it if necessary.
|
Loading…
Reference in New Issue
Block a user