doc updates
This commit is contained in:
255
tech_docs/cli_skills.md
Normal file
255
tech_docs/cli_skills.md
Normal file
@@ -0,0 +1,255 @@
|
|||||||
|
To improve your CLI skills, focusing on efficiency and mastery of shell commands, here are some tips and techniques:
|
||||||
|
|
||||||
|
1. **Use Aliases:**
|
||||||
|
Create aliases for commonly used commands to save time. For example:
|
||||||
|
```sh
|
||||||
|
alias cdp='cd ..'
|
||||||
|
alias ll='ls -la'
|
||||||
|
alias v='vim'
|
||||||
|
```
|
||||||
|
Add these to your `~/.bashrc` or `~/.zshrc` file.
|
||||||
|
|
||||||
|
2. **Navigation Shortcuts:**
|
||||||
|
- Use `cd -` to quickly switch to the previous directory.
|
||||||
|
- Use `cd` with shortcuts like `..` for parent directories or `~` for the home directory.
|
||||||
|
- Implement `pushd` and `popd` for managing directory stack:
|
||||||
|
```sh
|
||||||
|
pushd /path/to/directory
|
||||||
|
popd
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Tab Completion:**
|
||||||
|
Leverage tab completion to quickly fill in file and directory names.
|
||||||
|
|
||||||
|
4. **Search Command History:**
|
||||||
|
Use `Ctrl + r` to reverse search through your command history.
|
||||||
|
|
||||||
|
5. **Bash/Zsh Shortcuts:**
|
||||||
|
- `Ctrl + a` moves to the beginning of the line.
|
||||||
|
- `Ctrl + e` moves to the end of the line.
|
||||||
|
- `Ctrl + w` deletes the word before the cursor.
|
||||||
|
- `Ctrl + u` deletes from the cursor to the beginning of the line.
|
||||||
|
- `Ctrl + k` deletes from the cursor to the end of the line.
|
||||||
|
|
||||||
|
6. **Scripting:**
|
||||||
|
Write simple scripts for repetitive tasks. For example, to navigate to a commonly used directory and open a file:
|
||||||
|
```sh
|
||||||
|
#! /bin/bash
|
||||||
|
cd ~/repos/the_information_nexus/tech_docs/linux
|
||||||
|
vim vim.md
|
||||||
|
```
|
||||||
|
Save this as `edit_vim_docs.sh` and run it with `./edit_vim_docs.sh`.
|
||||||
|
|
||||||
|
7. **Combine Commands with && and ;:**
|
||||||
|
Combine commands on a single line to streamline workflows:
|
||||||
|
```sh
|
||||||
|
cd ~/repos/the_information_nexus/projects && vim The-Digital-Pulse-Series.md
|
||||||
|
```
|
||||||
|
|
||||||
|
8. **Use `find` and `grep`:**
|
||||||
|
Search for files and content within files efficiently:
|
||||||
|
```sh
|
||||||
|
find . -name '*.md'
|
||||||
|
grep -r 'search_term' .
|
||||||
|
```
|
||||||
|
|
||||||
|
9. **Keyboard Macros:**
|
||||||
|
Use `Ctrl + x` followed by `(` and `)` to start and end a keyboard macro in bash, which can be used to repeat a sequence of commands.
|
||||||
|
|
||||||
|
10. **Automation with `Makefile`:**
|
||||||
|
Use Makefiles to define commands you often run, simplifying complex workflows:
|
||||||
|
```makefile
|
||||||
|
edit_vim_docs:
|
||||||
|
cd ~/repos/the_information_nexus/tech_docs/linux && vim vim.md
|
||||||
|
```
|
||||||
|
|
||||||
|
11. **Learning Resources:**
|
||||||
|
- **Books:**
|
||||||
|
- "The Linux Command Line" by William Shotts
|
||||||
|
- "Learning the bash Shell" by Cameron Newham
|
||||||
|
- **Online Courses:**
|
||||||
|
- Codecademy's Command Line course
|
||||||
|
- Udemy's Linux Command Line Basics
|
||||||
|
|
||||||
|
12. **Experiment with Shell Customization:**
|
||||||
|
Customize your shell prompt to include useful information like the current directory, Git branch, etc. For example, using `oh-my-zsh`:
|
||||||
|
```sh
|
||||||
|
ZSH_THEME="agnoster"
|
||||||
|
```
|
||||||
|
|
||||||
|
Implementing these tips will help you become more efficient and powerful with your command-line skills.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
To enhance your Git skills, here are some detailed explanations and examples of commands and best practices:
|
||||||
|
|
||||||
|
### Basic Git Workflow
|
||||||
|
|
||||||
|
1. **Check Status:**
|
||||||
|
```sh
|
||||||
|
git status
|
||||||
|
```
|
||||||
|
- Shows the current state of your working directory and staging area.
|
||||||
|
- Use it frequently to keep track of changes.
|
||||||
|
|
||||||
|
2. **Add Changes:**
|
||||||
|
```sh
|
||||||
|
git add .
|
||||||
|
```
|
||||||
|
- Stages all changes in the working directory.
|
||||||
|
```sh
|
||||||
|
git add file_name
|
||||||
|
```
|
||||||
|
- Stages specific files.
|
||||||
|
|
||||||
|
3. **Commit Changes:**
|
||||||
|
```sh
|
||||||
|
git commit -m "Your commit message"
|
||||||
|
```
|
||||||
|
- Records the staged changes in the repository with a message.
|
||||||
|
- Use clear, descriptive messages. For example, "Fix typo in README.md".
|
||||||
|
|
||||||
|
4. **Push Changes:**
|
||||||
|
```sh
|
||||||
|
git push origin main
|
||||||
|
```
|
||||||
|
- Uploads your local commits to the remote repository.
|
||||||
|
- Ensure your local branch is up to date with `git pull` before pushing.
|
||||||
|
|
||||||
|
### Advanced Git Commands and Practices
|
||||||
|
|
||||||
|
1. **Interactive Add:**
|
||||||
|
```sh
|
||||||
|
git add -p
|
||||||
|
```
|
||||||
|
- Interactively review and stage changes hunk by hunk.
|
||||||
|
- Useful for staging specific parts of a file.
|
||||||
|
|
||||||
|
2. **Restore Changes:**
|
||||||
|
```sh
|
||||||
|
git restore <file>
|
||||||
|
```
|
||||||
|
- Discards changes in the working directory.
|
||||||
|
- For example, `git restore README.md` will revert changes to the file.
|
||||||
|
|
||||||
|
3. **Remove Files:**
|
||||||
|
```sh
|
||||||
|
git rm <file>
|
||||||
|
```
|
||||||
|
- Stages the removal of files from the repository.
|
||||||
|
- For example, `git rm old_file.txt` will remove and stage `old_file.txt` for deletion.
|
||||||
|
|
||||||
|
4. **Check Logs:**
|
||||||
|
```sh
|
||||||
|
git log
|
||||||
|
```
|
||||||
|
- Shows commit history.
|
||||||
|
```sh
|
||||||
|
git log --oneline --graph --decorate --all
|
||||||
|
```
|
||||||
|
- Provides a visual representation of commit history.
|
||||||
|
|
||||||
|
5. **Branching and Merging:**
|
||||||
|
```sh
|
||||||
|
git branch
|
||||||
|
```
|
||||||
|
- Lists all branches.
|
||||||
|
```sh
|
||||||
|
git branch new-branch
|
||||||
|
```
|
||||||
|
- Creates a new branch.
|
||||||
|
```sh
|
||||||
|
git checkout new-branch
|
||||||
|
```
|
||||||
|
- Switches to the specified branch.
|
||||||
|
```sh
|
||||||
|
git checkout -b new-branch
|
||||||
|
```
|
||||||
|
- Creates and switches to a new branch.
|
||||||
|
```sh
|
||||||
|
git merge new-branch
|
||||||
|
```
|
||||||
|
- Merges the specified branch into the current branch.
|
||||||
|
|
||||||
|
6. **Rebasing:**
|
||||||
|
```sh
|
||||||
|
git rebase main
|
||||||
|
```
|
||||||
|
- Integrates changes from another branch, maintaining a linear history.
|
||||||
|
- Use `git pull --rebase` to keep your branch updated.
|
||||||
|
|
||||||
|
7. **Stashing:**
|
||||||
|
```sh
|
||||||
|
git stash
|
||||||
|
```
|
||||||
|
- Temporarily saves changes.
|
||||||
|
```sh
|
||||||
|
git stash apply
|
||||||
|
```
|
||||||
|
- Applies stashed changes.
|
||||||
|
```sh
|
||||||
|
git stash list
|
||||||
|
```
|
||||||
|
- Lists all stashes.
|
||||||
|
|
||||||
|
8. **Resetting:**
|
||||||
|
```sh
|
||||||
|
git reset --soft HEAD~1
|
||||||
|
```
|
||||||
|
- Moves HEAD to the previous commit, keeping changes in the working directory.
|
||||||
|
```sh
|
||||||
|
git reset --hard HEAD~1
|
||||||
|
```
|
||||||
|
- Moves HEAD to the previous commit and discards changes.
|
||||||
|
|
||||||
|
9. **Tagging:**
|
||||||
|
```sh
|
||||||
|
git tag v1.0
|
||||||
|
```
|
||||||
|
- Creates a tag.
|
||||||
|
```sh
|
||||||
|
git push origin v1.0
|
||||||
|
```
|
||||||
|
- Pushes the tag to the remote repository.
|
||||||
|
|
||||||
|
10. **Reverting:**
|
||||||
|
```sh
|
||||||
|
git revert <commit>
|
||||||
|
```
|
||||||
|
- Creates a new commit that undoes changes of a specific commit.
|
||||||
|
- For example, `git revert abc1234` will undo changes from commit `abc1234`.
|
||||||
|
|
||||||
|
### Best Practices
|
||||||
|
|
||||||
|
1. **Write Meaningful Commit Messages:**
|
||||||
|
- Use the imperative mood: "Fix bug" instead of "Fixed bug".
|
||||||
|
- Separate subject from body with a blank line.
|
||||||
|
- Limit the subject line to 50 characters.
|
||||||
|
|
||||||
|
2. **Use Branches for Features and Bug Fixes:**
|
||||||
|
- Keep your main branch clean and stable.
|
||||||
|
|
||||||
|
3. **Regularly Pull and Rebase:**
|
||||||
|
- Keep your branch up to date with the main branch by regularly pulling and rebasing.
|
||||||
|
|
||||||
|
4. **Review Changes Before Committing:**
|
||||||
|
- Use `git diff` to review changes before staging and committing them.
|
||||||
|
|
||||||
|
### Additional Tools and Resources
|
||||||
|
|
||||||
|
1. **Graphical Interfaces:**
|
||||||
|
- Tools like GitKraken, Sourcetree, or GitHub Desktop can help visualize changes and manage branches.
|
||||||
|
|
||||||
|
2. **Learning Resources:**
|
||||||
|
- Books: "Pro Git" by Scott Chacon and Ben Straub.
|
||||||
|
- Online Courses: GitHub Learning Lab, Codecademy, and Udacity.
|
||||||
|
|
||||||
|
3. **Automation with Git Hooks:**
|
||||||
|
- Automate tasks with Git hooks (e.g., pre-commit, post-commit).
|
||||||
|
```sh
|
||||||
|
# .git/hooks/pre-commit
|
||||||
|
#!/bin/sh
|
||||||
|
npm test
|
||||||
|
```
|
||||||
|
|
||||||
|
Implementing these advanced commands and best practices will help you become more proficient with Git, making version control and collaboration smoother and more efficient.
|
||||||
296
tech_docs/git.md
296
tech_docs/git.md
@@ -1,3 +1,299 @@
|
|||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
To enhance your Git skills, here's a breakdown of the commands you already know and some additional commands and practices that can help you work more efficiently:
|
||||||
|
|
||||||
|
### Basic Git Workflow
|
||||||
|
|
||||||
|
1. **Check Status:**
|
||||||
|
```sh
|
||||||
|
git status
|
||||||
|
```
|
||||||
|
This shows the current state of your working directory and staging area.
|
||||||
|
|
||||||
|
2. **Add Changes:**
|
||||||
|
```sh
|
||||||
|
git add .
|
||||||
|
git add file_name
|
||||||
|
```
|
||||||
|
The first command stages all changes, while the second stages specific files.
|
||||||
|
|
||||||
|
3. **Commit Changes:**
|
||||||
|
```sh
|
||||||
|
git commit -m "Your commit message"
|
||||||
|
```
|
||||||
|
This records the staged changes in the repository with a message.
|
||||||
|
|
||||||
|
4. **Push Changes:**
|
||||||
|
```sh
|
||||||
|
git push origin main
|
||||||
|
```
|
||||||
|
This uploads your local commits to the remote repository.
|
||||||
|
|
||||||
|
### Advanced Git Commands and Practices
|
||||||
|
|
||||||
|
1. **Interactive Add:**
|
||||||
|
```sh
|
||||||
|
git add -p
|
||||||
|
```
|
||||||
|
This allows you to interactively review and stage changes hunk by hunk.
|
||||||
|
|
||||||
|
2. **Restore Changes:**
|
||||||
|
```sh
|
||||||
|
git restore <file>
|
||||||
|
```
|
||||||
|
This discards changes in the working directory.
|
||||||
|
|
||||||
|
3. **Remove Files:**
|
||||||
|
```sh
|
||||||
|
git rm <file>
|
||||||
|
```
|
||||||
|
This stages the removal of files from the repository.
|
||||||
|
|
||||||
|
4. **Check Logs:**
|
||||||
|
```sh
|
||||||
|
git log
|
||||||
|
git log --oneline --graph --decorate --all
|
||||||
|
```
|
||||||
|
These commands show commit history. The second one provides a more visual representation.
|
||||||
|
|
||||||
|
5. **Branching and Merging:**
|
||||||
|
```sh
|
||||||
|
git branch
|
||||||
|
git branch new-branch
|
||||||
|
git checkout new-branch
|
||||||
|
git checkout -b new-branch
|
||||||
|
git merge new-branch
|
||||||
|
```
|
||||||
|
These commands manage branches, allowing you to create, switch, and merge branches.
|
||||||
|
|
||||||
|
6. **Rebase:**
|
||||||
|
```sh
|
||||||
|
git rebase main
|
||||||
|
```
|
||||||
|
This integrates changes from another branch into your current branch, maintaining a linear history.
|
||||||
|
|
||||||
|
7. **Stashing:**
|
||||||
|
```sh
|
||||||
|
git stash
|
||||||
|
git stash apply
|
||||||
|
git stash list
|
||||||
|
```
|
||||||
|
These commands temporarily save changes that aren’t ready to be committed.
|
||||||
|
|
||||||
|
8. **Resetting:**
|
||||||
|
```sh
|
||||||
|
git reset --soft HEAD~1
|
||||||
|
git reset --hard HEAD~1
|
||||||
|
```
|
||||||
|
These commands undo changes by resetting to a previous commit. The first keeps changes in the working directory, while the second discards them.
|
||||||
|
|
||||||
|
9. **Tagging:**
|
||||||
|
```sh
|
||||||
|
git tag v1.0
|
||||||
|
git push origin v1.0
|
||||||
|
```
|
||||||
|
These commands create and push tags for marking specific points in history.
|
||||||
|
|
||||||
|
10. **Reverting:**
|
||||||
|
```sh
|
||||||
|
git revert <commit>
|
||||||
|
```
|
||||||
|
This creates a new commit that undoes the changes of a specific commit.
|
||||||
|
|
||||||
|
### Best Practices
|
||||||
|
|
||||||
|
1. **Write Meaningful Commit Messages:**
|
||||||
|
- Use imperative mood: "Fix bug" instead of "Fixed bug".
|
||||||
|
- Separate subject from body with a blank line.
|
||||||
|
- Limit the subject line to 50 characters.
|
||||||
|
|
||||||
|
2. **Use Branches for Features and Bug Fixes:**
|
||||||
|
- Create separate branches for different features or fixes to keep your main branch clean and stable.
|
||||||
|
|
||||||
|
3. **Regularly Pull and Rebase:**
|
||||||
|
- Keep your branch up to date with the main branch by regularly pulling and rebasing.
|
||||||
|
|
||||||
|
4. **Review Changes Before Committing:**
|
||||||
|
- Use `git diff` to review changes before staging and committing them.
|
||||||
|
|
||||||
|
By incorporating these advanced commands and best practices into your workflow, you'll become more proficient with Git and improve your version control practices.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Detailed Explanations and Examples
|
||||||
|
|
||||||
|
#### 1. **Checking Status:**
|
||||||
|
```sh
|
||||||
|
git status
|
||||||
|
```
|
||||||
|
- Shows the current state of the working directory and staging area.
|
||||||
|
- Use it frequently to keep track of changes.
|
||||||
|
|
||||||
|
#### 2. **Adding Changes:**
|
||||||
|
```sh
|
||||||
|
git add .
|
||||||
|
```
|
||||||
|
- Stages all changes in the working directory.
|
||||||
|
```sh
|
||||||
|
git add file_name
|
||||||
|
```
|
||||||
|
- Stages specific files.
|
||||||
|
|
||||||
|
#### 3. **Committing Changes:**
|
||||||
|
```sh
|
||||||
|
git commit -m "Your commit message"
|
||||||
|
```
|
||||||
|
- Records the staged changes with a message.
|
||||||
|
- Use clear, descriptive messages. For example, "Fix typo in README.md".
|
||||||
|
|
||||||
|
#### 4. **Pushing Changes:**
|
||||||
|
```sh
|
||||||
|
git push origin main
|
||||||
|
```
|
||||||
|
- Uploads local commits to the remote repository.
|
||||||
|
- Ensure your local branch is up to date with `git pull` before pushing.
|
||||||
|
|
||||||
|
### Advanced Git Commands and Practices
|
||||||
|
|
||||||
|
#### 1. **Interactive Add:**
|
||||||
|
```sh
|
||||||
|
git add -p
|
||||||
|
```
|
||||||
|
- Interactively review and stage changes hunk by hunk.
|
||||||
|
- Useful for staging specific parts of a file.
|
||||||
|
|
||||||
|
#### 2. **Restoring Changes:**
|
||||||
|
```sh
|
||||||
|
git restore <file>
|
||||||
|
```
|
||||||
|
- Discards changes in the working directory.
|
||||||
|
- For example, `git restore README.md` will revert changes to the file.
|
||||||
|
|
||||||
|
#### 3. **Removing Files:**
|
||||||
|
```sh
|
||||||
|
git rm <file>
|
||||||
|
```
|
||||||
|
- Stages the removal of files from the repository.
|
||||||
|
- For example, `git rm old_file.txt` will remove and stage `old_file.txt` for deletion.
|
||||||
|
|
||||||
|
#### 4. **Checking Logs:**
|
||||||
|
```sh
|
||||||
|
git log
|
||||||
|
```
|
||||||
|
- Shows commit history.
|
||||||
|
```sh
|
||||||
|
git log --oneline --graph --decorate --all
|
||||||
|
```
|
||||||
|
- Provides a visual representation of commit history.
|
||||||
|
|
||||||
|
#### 5. **Branching and Merging:**
|
||||||
|
```sh
|
||||||
|
git branch
|
||||||
|
```
|
||||||
|
- Lists all branches.
|
||||||
|
```sh
|
||||||
|
git branch new-branch
|
||||||
|
```
|
||||||
|
- Creates a new branch.
|
||||||
|
```sh
|
||||||
|
git checkout new-branch
|
||||||
|
```
|
||||||
|
- Switches to the specified branch.
|
||||||
|
```sh
|
||||||
|
git checkout -b new-branch
|
||||||
|
```
|
||||||
|
- Creates and switches to a new branch.
|
||||||
|
```sh
|
||||||
|
git merge new-branch
|
||||||
|
```
|
||||||
|
- Merges the specified branch into the current branch.
|
||||||
|
|
||||||
|
#### 6. **Rebasing:**
|
||||||
|
```sh
|
||||||
|
git rebase main
|
||||||
|
```
|
||||||
|
- Integrates changes from another branch, maintaining a linear history.
|
||||||
|
- Use `git pull --rebase` to keep your branch updated.
|
||||||
|
|
||||||
|
#### 7. **Stashing:**
|
||||||
|
```sh
|
||||||
|
git stash
|
||||||
|
```
|
||||||
|
- Temporarily saves changes.
|
||||||
|
```sh
|
||||||
|
git stash apply
|
||||||
|
```
|
||||||
|
- Applies stashed changes.
|
||||||
|
```sh
|
||||||
|
git stash list
|
||||||
|
```
|
||||||
|
- Lists all stashes.
|
||||||
|
|
||||||
|
#### 8. **Resetting:**
|
||||||
|
```sh
|
||||||
|
git reset --soft HEAD~1
|
||||||
|
```
|
||||||
|
- Moves HEAD to the previous commit, keeping changes in the working directory.
|
||||||
|
```sh
|
||||||
|
git reset --hard HEAD~1
|
||||||
|
```
|
||||||
|
- Moves HEAD to the previous commit and discards changes.
|
||||||
|
|
||||||
|
#### 9. **Tagging:**
|
||||||
|
```sh
|
||||||
|
git tag v1.0
|
||||||
|
```
|
||||||
|
- Creates a tag.
|
||||||
|
```sh
|
||||||
|
git push origin v1.0
|
||||||
|
```
|
||||||
|
- Pushes the tag to the remote repository.
|
||||||
|
|
||||||
|
#### 10. **Reverting:**
|
||||||
|
```sh
|
||||||
|
git revert <commit>
|
||||||
|
```
|
||||||
|
- Creates a new commit that undoes changes of a specific commit.
|
||||||
|
- For example, `git revert abc1234` will undo changes from commit `abc1234`.
|
||||||
|
|
||||||
|
### Best Practices
|
||||||
|
|
||||||
|
1. **Write Meaningful Commit Messages:**
|
||||||
|
- Use the imperative mood: "Fix bug" instead of "Fixed bug".
|
||||||
|
- Separate subject from body with a blank line.
|
||||||
|
- Limit the subject line to 50 characters.
|
||||||
|
|
||||||
|
2. **Use Branches for Features and Bug Fixes:**
|
||||||
|
- Keep your main branch clean and stable.
|
||||||
|
|
||||||
|
3. **Regularly Pull and Rebase:**
|
||||||
|
- Keep your branch up to date with the main branch by regularly pulling and rebasing.
|
||||||
|
|
||||||
|
4. **Review Changes Before Committing:**
|
||||||
|
- Use `git diff` to review changes before staging and committing them.
|
||||||
|
|
||||||
|
### Additional Tools and Resources
|
||||||
|
|
||||||
|
1. **Graphical Interfaces:**
|
||||||
|
- Tools like GitKraken, Sourcetree, or GitHub Desktop can help visualize changes and manage branches.
|
||||||
|
|
||||||
|
2. **Learning Resources:**
|
||||||
|
- Books: "Pro Git" by Scott Chacon and Ben Straub.
|
||||||
|
- Online Courses: GitHub Learning Lab, Codecademy, and Udacity.
|
||||||
|
|
||||||
|
3. **Automation with Git Hooks:**
|
||||||
|
- Automate tasks with Git hooks (e.g., pre-commit, post-commit).
|
||||||
|
```sh
|
||||||
|
# .git/hooks/pre-commit
|
||||||
|
#!/bin/sh
|
||||||
|
npm test
|
||||||
|
```
|
||||||
|
|
||||||
|
Implementing these advanced commands and best practices will help you become more proficient with Git, making version control and collaboration smoother and more efficient.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
Sure, I'll walk you through your Git configuration based on the `.git/config` file you've shown. This file is specific to your Ansible repository and defines settings and rules that Git will follow for this particular repository. Let's break down each section:
|
Sure, I'll walk you through your Git configuration based on the `.git/config` file you've shown. This file is specific to your Ansible repository and defines settings and rules that Git will follow for this particular repository. Let's break down each section:
|
||||||
|
|
||||||
### Core Section
|
### Core Section
|
||||||
|
|||||||
@@ -1,3 +1,194 @@
|
|||||||
|
To improve your CLI skills, focusing on efficiency and mastery of shell commands, here are some tips and techniques:
|
||||||
|
|
||||||
|
1. **Use Aliases:**
|
||||||
|
Create aliases for commonly used commands to save time. For example:
|
||||||
|
```sh
|
||||||
|
alias cdp='cd ..'
|
||||||
|
alias ll='ls -la'
|
||||||
|
alias v='vim'
|
||||||
|
```
|
||||||
|
Add these to your `~/.bashrc` or `~/.zshrc` file.
|
||||||
|
|
||||||
|
2. **Navigation Shortcuts:**
|
||||||
|
- Use `cd -` to quickly switch to the previous directory.
|
||||||
|
- Use `cd` with shortcuts like `..` for parent directories or `~` for the home directory.
|
||||||
|
- Implement `pushd` and `popd` for managing directory stack:
|
||||||
|
```sh
|
||||||
|
pushd /path/to/directory
|
||||||
|
popd
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Tab Completion:**
|
||||||
|
Leverage tab completion to quickly fill in file and directory names.
|
||||||
|
|
||||||
|
4. **Search Command History:**
|
||||||
|
Use `Ctrl + r` to reverse search through your command history.
|
||||||
|
|
||||||
|
5. **Bash/Zsh Shortcuts:**
|
||||||
|
- `Ctrl + a` moves to the beginning of the line.
|
||||||
|
- `Ctrl + e` moves to the end of the line.
|
||||||
|
- `Ctrl + w` deletes the word before the cursor.
|
||||||
|
- `Ctrl + u` deletes from the cursor to the beginning of the line.
|
||||||
|
- `Ctrl + k` deletes from the cursor to the end of the line.
|
||||||
|
|
||||||
|
6. **Scripting:**
|
||||||
|
Write simple scripts for repetitive tasks. For example, to navigate to a commonly used directory and open a file:
|
||||||
|
```sh
|
||||||
|
#! /bin/bash
|
||||||
|
cd ~/repos/the_information_nexus/tech_docs/linux
|
||||||
|
vim vim.md
|
||||||
|
```
|
||||||
|
Save this as `edit_vim_docs.sh` and run it with `./edit_vim_docs.sh`.
|
||||||
|
|
||||||
|
7. **Combine Commands with && and ;:**
|
||||||
|
Combine commands on a single line to streamline workflows:
|
||||||
|
```sh
|
||||||
|
cd ~/repos/the_information_nexus/projects && vim The-Digital-Pulse-Series.md
|
||||||
|
```
|
||||||
|
|
||||||
|
8. **Use `find` and `grep`:**
|
||||||
|
Search for files and content within files efficiently:
|
||||||
|
```sh
|
||||||
|
find . -name '*.md'
|
||||||
|
grep -r 'search_term' .
|
||||||
|
```
|
||||||
|
|
||||||
|
9. **Keyboard Macros:**
|
||||||
|
Use `Ctrl + x` followed by `(` and `)` to start and end a keyboard macro in bash, which can be used to repeat a sequence of commands.
|
||||||
|
|
||||||
|
10. **Automation with `Makefile`:**
|
||||||
|
Use Makefiles to define commands you often run, simplifying complex workflows:
|
||||||
|
```makefile
|
||||||
|
edit_vim_docs:
|
||||||
|
cd ~/repos/the_information_nexus/tech_docs/linux && vim vim.md
|
||||||
|
```
|
||||||
|
|
||||||
|
11. **Learning Resources:**
|
||||||
|
- **Books:**
|
||||||
|
- "The Linux Command Line" by William Shotts
|
||||||
|
- "Learning the bash Shell" by Cameron Newham
|
||||||
|
- **Online Courses:**
|
||||||
|
- Codecademy's Command Line course
|
||||||
|
- Udemy's Linux Command Line Basics
|
||||||
|
|
||||||
|
12. **Experiment with Shell Customization:**
|
||||||
|
Customize your shell prompt to include useful information like the current directory, Git branch, etc. For example, using `oh-my-zsh`:
|
||||||
|
```sh
|
||||||
|
ZSH_THEME="agnoster"
|
||||||
|
```
|
||||||
|
|
||||||
|
Implementing these tips will help you become more efficient and powerful with your command-line skills.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Sure, let's start from the beginning and set up Vim with syntax highlighting support for Markdown, Python, and JavaScript on your Debian 12 system.
|
||||||
|
|
||||||
|
### Step-by-Step Guide
|
||||||
|
|
||||||
|
#### Step 1: Install Vim
|
||||||
|
|
||||||
|
1. **Open your terminal.**
|
||||||
|
2. **Update your package list:**
|
||||||
|
```sh
|
||||||
|
sudo apt update
|
||||||
|
```
|
||||||
|
3. **Install Vim:**
|
||||||
|
```sh
|
||||||
|
sudo apt install vim
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Step 2: Install Vim-Plug (Plugin Manager)
|
||||||
|
|
||||||
|
1. **Install Vim-Plug:**
|
||||||
|
```sh
|
||||||
|
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
|
||||||
|
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Step 3: Configure `.vimrc` File
|
||||||
|
|
||||||
|
1. **Create or open your `.vimrc` file:**
|
||||||
|
```sh
|
||||||
|
vim ~/.vimrc
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Add the following configuration to your `.vimrc` file:**
|
||||||
|
|
||||||
|
```vim
|
||||||
|
" Enable syntax highlighting
|
||||||
|
syntax on
|
||||||
|
|
||||||
|
" Set line numbers
|
||||||
|
set number
|
||||||
|
|
||||||
|
" Enable filetype detection and plugins
|
||||||
|
filetype plugin on
|
||||||
|
filetype indent on
|
||||||
|
|
||||||
|
" Set basic editing settings
|
||||||
|
set tabstop=4
|
||||||
|
set shiftwidth=4
|
||||||
|
set expandtab
|
||||||
|
set autoindent
|
||||||
|
set smartindent
|
||||||
|
|
||||||
|
" Enable mouse support
|
||||||
|
set mouse=a
|
||||||
|
|
||||||
|
" Initialize Vim-Plug
|
||||||
|
call plug#begin('~/.vim/plugged')
|
||||||
|
|
||||||
|
" Markdown plugin for syntax highlighting
|
||||||
|
Plug 'plasticboy/vim-markdown'
|
||||||
|
|
||||||
|
" Python syntax highlighting
|
||||||
|
Plug 'vim-python/python-syntax'
|
||||||
|
|
||||||
|
" JavaScript syntax highlighting
|
||||||
|
Plug 'pangloss/vim-javascript'
|
||||||
|
|
||||||
|
call plug#end()
|
||||||
|
|
||||||
|
" Disable folding for Markdown files
|
||||||
|
let g:vim_markdown_folding_disabled = 1
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Save and exit the `.vimrc` file:**
|
||||||
|
Press `Esc`, then type `:wq` and hit `Enter`.
|
||||||
|
|
||||||
|
#### Step 4: Install the Plugins
|
||||||
|
|
||||||
|
1. **Open Vim:**
|
||||||
|
```sh
|
||||||
|
vim
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Install the plugins by running the following command in Vim:**
|
||||||
|
```vim
|
||||||
|
:PlugInstall
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Step 5: Verify Syntax Highlighting
|
||||||
|
|
||||||
|
1. **Open a Markdown file to check syntax highlighting:**
|
||||||
|
```sh
|
||||||
|
vim yourfile.md
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Open a Python file to check syntax highlighting:**
|
||||||
|
```sh
|
||||||
|
vim yourfile.py
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Open a JavaScript file to check syntax highlighting:**
|
||||||
|
```sh
|
||||||
|
vim yourfile.js
|
||||||
|
```
|
||||||
|
|
||||||
|
By following these steps, you should have Vim installed with syntax highlighting support for Markdown, Python, and JavaScript. The configuration ensures that your `.vimrc` is properly set up to use Vim-Plug for managing plugins, and you can enjoy enhanced editing features for these file types.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
In Vim, to move to the top of the document, select all text, and then either delete or yank (copy) it, you'll use different sequences of commands depending on what you want to accomplish. Here are the steps for each action:
|
In Vim, to move to the top of the document, select all text, and then either delete or yank (copy) it, you'll use different sequences of commands depending on what you want to accomplish. Here are the steps for each action:
|
||||||
|
|
||||||
1. **Move to the Top and Select All Text**:
|
1. **Move to the Top and Select All Text**:
|
||||||
|
|||||||
Reference in New Issue
Block a user