From 9012a85e304fb4573ae2b97d2e3567e80bb4d68c Mon Sep 17 00:00:00 2001 From: Mikael Johansson Date: Sun, 14 Jun 2026 12:47:24 +0200 Subject: [PATCH] Updated formattting --- cpp-cheatsheet.md | 28 ++++++++--------- git-cheatsheet.md | 52 +++++++++++++++---------------- wsl-ubuntu-cheatsheet.md | 66 ++++++++++++++++++++-------------------- 3 files changed, 73 insertions(+), 73 deletions(-) diff --git a/cpp-cheatsheet.md b/cpp-cheatsheet.md index 5925de5..6b49956 100644 --- a/cpp-cheatsheet.md +++ b/cpp-cheatsheet.md @@ -17,22 +17,22 @@ int main() { | Command | What it does | Example | |---------|-------------|---------| -| `clang++ ` | Compile to an executable named `a.out` | `clang++ hello.cpp` | -| `clang++ -o ` | Compile and name the output | `clang++ hello.cpp -o hello` | -| `clang++ -Wall ` | Enable **all** warnings (always use this!) | `clang++ -Wall hello.cpp -o hello` | -| `clang++ -std=c++17 ` | Use a specific C++ version | `clang++ -std=c++20 -Wall prog.cpp -o prog` | -| `clang++ -g ` | Include debug info (for use with a debugger) | `clang++ -g -Wall hello.cpp -o hello` | +| clang++ | Compile to an executable named a.out | clang++ hello.cpp | +| clang++ -o | Compile and name the output | clang++ hello.cpp -o hello | +| clang++ -Wall | Enable **all** warnings (always use this!) | clang++ -Wall hello.cpp -o hello | +| clang++ -std=c++17 | Use a specific C++ version | clang++ -std=c++20 -Wall prog.cpp -o prog | +| clang++ -g | Include debug info (for use with a debugger) | clang++ -g -Wall hello.cpp -o hello | **Common flags explained:** | Flag | Meaning | |------|---------| -| `-o ` | Output filename (instead of `a.out`) | -| `-Wall` | Enable most compiler warnings | -| `-Wextra` | Enable even more warnings | -| `-std=c++17` | Use C++17 standard (also `c++11`, `c++14`, `c++20`) | -| `-g` | Include debug symbols (for `gdb` or `lldb`) | -| `-O2` | Optimize for speed | +| -o | Output filename (instead of a.out) | +| -Wall | Enable most compiler warnings | +| -Wextra | Enable even more warnings | +| -std=c++17 | Use C++17 standard (also c++11, c++14, c++20) | +| -g | Include debug symbols (for gdb or lldb) | +| -O2 | Optimize for speed | ### Full compile example ```bash @@ -91,9 +91,9 @@ clean: | Command | What it does | |---------|-------------| -| `make` | Build the program | -| `make clean` | Delete the compiled program | -| `make -j4` | Build using 4 CPU cores (faster) | +| make | Build the program | +| make clean | Delete the compiled program | +| make -j4 | Build using 4 CPU cores (faster) | ### Typical Makefile with separate compilation ```make diff --git a/git-cheatsheet.md b/git-cheatsheet.md index 058080b..21108f9 100644 --- a/git-cheatsheet.md +++ b/git-cheatsheet.md @@ -4,15 +4,15 @@ | Command | What it does | Example | |---------|-------------|---------| -| `git config --global user.name "Your Name"` | Set your name on commits | `git config --global user.name "Alice"` | -| `git config --global user.email "a@b.com"` | Set your email on commits | `git config --global user.email "alice@example.com"` | +| git config --global user.name "Your Name" | Set your name on commits | git config --global user.name "Alice" | +| git config --global user.email "a@b.com" | Set your email on commits | git config --global user.email "alice@example.com" | ## Starting a Project | Command | What it does | Example | |---------|-------------|---------| -| `git init` | Turn the current folder into a Git repo | `cd my_project && git init` | -| `git clone ` | Download an existing repo from GitHub etc. | `git clone https://github.com/user/repo.git` | +| git init | Turn the current folder into a Git repo | cd my_project && git init | +| git clone | Download an existing repo from GitHub etc. | git clone https://github.com/user/repo.git | ## Everyday Workflow @@ -25,43 +25,43 @@ | Command | What it does | Example | |---------|-------------|---------| -| `git status` | See what files changed and what's staged | `git status` | -| `git add ` | Stage a file for commit | `git add main.cpp` | -| `git add .` | Stage **all** changed files | `git add .` | -| `git commit -m "message"` | Save staged changes with a message | `git commit -m "Add login feature"` | -| `git log` | Show commit history | `git log --oneline` (compact view) | -| `git diff` | Show unstaged changes (line by line) | `git diff` | +| git status | See what files changed and what's staged | git status | +| git add | Stage a file for commit | git add main.cpp | +| git add . | Stage **all** changed files | git add . | +| git commit -m "message" | Save staged changes with a message | git commit -m "Add login feature" | +| git log | Show commit history | git log --oneline (compact view) | +| git diff | Show unstaged changes (line by line) | git diff | ## Undoing Things | Command | What it does | Example | |---------|-------------|---------| -| `git restore ` | Discard unstaged changes in a file | `git restore main.cpp` | -| `git restore --staged ` | Unstage a file (keep your edits) | `git restore --staged main.cpp` | -| `git commit --amend -m "new msg"` | Fix the last commit message | `git commit --amend -m "Fixed message"` | -| `git reset --hard HEAD` | Throw away **all** uncommitted changes ⚠️ | Use with care! | +| git restore | Discard unstaged changes in a file | git restore main.cpp | +| git restore --staged | Unstage a file (keep your edits) | git restore --staged main.cpp | +| git commit --amend -m "new msg" | Fix the last commit message | git commit --amend -m "Fixed message" | +| git reset --hard HEAD | Throw away **all** uncommitted changes ⚠️ | Use with care! | ## Branches | Command | What it does | Example | |---------|-------------|---------| -| `git branch` | List branches (`*` = current one) | `git branch` | -| `git branch ` | Create a new branch | `git branch feature-x` | -| `git checkout ` | Switch to a branch | `git checkout feature-x` | -| `git switch ` | Switch to a branch (newer syntax) | `git switch main` | -| `git checkout -b ` | Create **and** switch to a new branch | `git checkout -b feature-x` | -| `git merge ` | Merge another branch into the current one | `git switch main && git merge feature-x` | -| `git branch -d ` | Delete a branch (safe) | `git branch -d feature-x` | +| git branch | List branches (* = current one) | git branch | +| git branch | Create a new branch | git branch feature-x | +| git checkout | Switch to a branch | git checkout feature-x | +| git switch | Switch to a branch (newer syntax) | git switch main | +| git checkout -b | Create **and** switch to a new branch | git checkout -b feature-x | +| git merge | Merge another branch into the current one | git switch main && git merge feature-x | +| git branch -d | Delete a branch (safe) | git branch -d feature-x | ## Working with GitHub (Remote) | Command | What it does | Example | |---------|-------------|---------| -| `git remote add origin ` | Link your local repo to GitHub | `git remote add origin https://github.com/alice/my-project.git` | -| `git push -u origin main` | Push commits to GitHub (first time) | `git push -u origin main` | -| `git push` | Push commits (after first time) | `git push` | -| `git pull` | Fetch and merge the latest from GitHub | `git pull` | -| `git fetch` | Download updates from GitHub (don't merge) | `git fetch` | +| git remote add origin | Link your local repo to GitHub | git remote add origin https://github.com/alice/my-project.git | +| git push -u origin main | Push commits to GitHub (first time) | git push -u origin main | +| git push | Push commits (after first time) | git push | +| git pull | Fetch and merge the latest from GitHub | git pull | +| git fetch | Download updates from GitHub (don't merge) | git fetch | ## Common Scenarios diff --git a/wsl-ubuntu-cheatsheet.md b/wsl-ubuntu-cheatsheet.md index 718304a..303475f 100644 --- a/wsl-ubuntu-cheatsheet.md +++ b/wsl-ubuntu-cheatsheet.md @@ -4,59 +4,59 @@ | Command | What it does | Example | |---------|-------------|---------| -| `pwd` | Print the current directory (where you are) | `pwd` → `/home/alice` | -| `ls` | List files and folders | `ls`, `ls -la` (detailed view) | -| `cd ` | Change directory | `cd Documents`, `cd ~` (home), `cd ..` (up one) | -| `mkdir ` | Create a new directory | `mkdir projects` | -| `rmdir ` | Remove an **empty** directory | `rmdir old_folder` | +| pwd | Print the current directory (where you are) | pwd → /home/alice | +| ls | List files and folders | ls, ls -la (detailed view) | +| cd | Change directory | cd Documents, cd ~ (home), cd .. (up one) | +| mkdir | Create a new directory | mkdir projects | +| rmdir | Remove an **empty** directory | rmdir old_folder | ## File Operations | Command | What it does | Example | |---------|-------------|---------| -| `touch ` | Create an empty file | `touch notes.txt` | -| `cp ` | Copy a file | `cp notes.txt backup.txt` | -| `mv ` | Move or rename a file | `mv notes.txt ~/Documents/` | -| `rm ` | Delete a file (⚠️ no trash bin) | `rm temp.txt` | -| `rm -r ` | Delete a folder and **everything inside** | `rm -r old_project/` | -| `cat ` | Print a file's contents to the terminal | `cat notes.txt` | -| `less ` | View a file page-by-page (press `q` to quit) | `less long_file.txt` | -| `head ` | Show the first 10 lines | `head data.csv` | -| `tail ` | Show the last 10 lines | `tail -n 20 data.csv` | -| `nano ` | Edit a file in the terminal | `nano notes.txt` | +| touch | Create an empty file | touch notes.txt | +| cp | Copy a file | cp notes.txt backup.txt | +| mv | Move or rename a file | mv notes.txt ~/Documents/ | +| rm | Delete a file (⚠️ no trash bin) | rm temp.txt | +| rm -r | Delete a folder and **everything inside** | rm -r old_project/ | +| cat | Print a file's contents to the terminal | cat notes.txt | +| less | View a file page-by-page (press q to quit) | less long_file.txt | +| head | Show the first 10 lines | head data.csv | +| tail | Show the last 10 lines | tail -n 20 data.csv | +| nano | Edit a file in the terminal | nano notes.txt | ## Viewing & Finding | Command | What it does | Example | |---------|-------------|---------| -| `file ` | Show what type of file something is | `file notes.txt` | -| `find -name ` | Find files by name | `find ~ -name "*.md"` | -| `grep ` | Search inside files | `grep "error" log.txt` | +| file | Show what type of file something is | file notes.txt | +| find -name | Find files by name | find ~ -name "*.md" | +| grep | Search inside files | grep "error" log.txt | ## Permissions | Command | What it does | Example | |---------|-------------|---------| -| `chmod ` | Change file permissions | `chmod +x script.sh` (make executable) | -| `sudo ` | Run a command as admin (root) | `sudo apt update` | +| chmod | Change file permissions | chmod +x script.sh (make executable) | +| sudo | Run a command as admin (root) | sudo apt update | ## Package Management (apt) | Command | What it does | Example | |---------|-------------|---------| -| `sudo apt update` | Refresh the list of available packages | Run before installing anything | -| `sudo apt install ` | Install a package | `sudo apt install clang` | -| `sudo apt upgrade` | Upgrade all installed packages | `sudo apt upgrade` | -| `sudo apt remove ` | Uninstall a package | `sudo apt remove clang` | -| `apt search ` | Search for a package | `apt search image editor` | +| sudo apt update | Refresh the list of available packages | Run before installing anything | +| sudo apt install | Install a package | sudo apt install clang | +| sudo apt upgrade | Upgrade all installed packages | sudo apt upgrade | +| sudo apt remove | Uninstall a package | sudo apt remove clang | +| apt search | Search for a package | apt search image editor | ## Pipes & Redirection | Command | What it does | Example | |---------|-------------|---------| -| `cmd1 \| cmd2` | Send output of `cmd1` into `cmd2` | `ls \| grep ".txt"` | -| `>` | Redirect output to a file (overwrite) | `echo "hello" > hello.txt` | -| `>>` | Redirect output to a file (append) | `echo "world" >> hello.txt` | +| cmd1 \| cmd2 | Send output of cmd1 into cmd2 | ls \| grep ".txt" | +| > | Redirect output to a file (overwrite) | echo "hello" > hello.txt | +| >> | Redirect output to a file (append) | echo "world" >> hello.txt | ## WSL-Specific Tips @@ -69,11 +69,11 @@ | Shortcut | What it does | |----------|-------------| -| `Ctrl + C` | Cancel the current command | -| `Ctrl + D` | Exit the terminal / close session | -| `Tab` | Auto-complete file and folder names | -| `↑` / `↓` | Scroll through command history | -| `Ctrl + L` | Clear the screen | +| Ctrl + C | Cancel the current command | +| Ctrl + D | Exit the terminal / close session | +| Tab | Auto-complete file and folder names | +| ↑ / ↓ | Scroll through command history | +| Ctrl + L | Clear the screen | ## Quick Reference — First Steps