{"id":17160371,"url":"https://github.com/codenameyau/dotfiles","last_synced_at":"2026-02-24T09:33:02.743Z","repository":{"id":17093932,"uuid":"19859242","full_name":"codenameyau/dotfiles","owner":"codenameyau","description":":neckbeard: My knowledge of all things linux, servers, and bash with config files","archived":false,"fork":false,"pushed_at":"2023-10-16T04:06:28.000Z","size":355,"stargazers_count":20,"open_issues_count":3,"forks_count":13,"subscribers_count":5,"default_branch":"master","last_synced_at":"2026-01-14T09:03:08.344Z","etag":null,"topics":["bash","bashrc","caddy","command-line","config","curl","dotfiles","git","gitconfig","githook","linux","nginx","provisioning","raspberry-pi","scripts","shell","unix","vimrc","vscode"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codenameyau.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2014-05-16T14:25:33.000Z","updated_at":"2025-04-29T23:14:41.000Z","dependencies_parsed_at":"2022-08-26T11:33:52.258Z","dependency_job_id":"e0f1b46b-ebb2-4917-843e-dcc2aba7a859","html_url":"https://github.com/codenameyau/dotfiles","commit_stats":null,"previous_names":["codenameyau/editor"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/codenameyau/dotfiles","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codenameyau%2Fdotfiles","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codenameyau%2Fdotfiles/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codenameyau%2Fdotfiles/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codenameyau%2Fdotfiles/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codenameyau","download_url":"https://codeload.github.com/codenameyau/dotfiles/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codenameyau%2Fdotfiles/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29777887,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-24T04:54:30.205Z","status":"ssl_error","status_checked_at":"2026-02-24T04:53:58.628Z","response_time":75,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","bashrc","caddy","command-line","config","curl","dotfiles","git","gitconfig","githook","linux","nginx","provisioning","raspberry-pi","scripts","shell","unix","vimrc","vscode"],"created_at":"2024-10-14T22:24:38.984Z","updated_at":"2026-02-24T09:33:02.697Z","avatar_url":"https://github.com/codenameyau.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Helpful Resources\n- Official GNU reference: https://www.gnu.org/software/bash/manual/html_node/index.html\n- Bash Guide for Beginners: https://www.tldp.org/LDP/Bash-Beginners-Guide/html/\n- Bash Cheatsheet: https://mywiki.wooledge.org/BashSheet\n\n## Table of Contents\n\n- [Helpful Resources](#helpful-resources)\n- [Table of Contents](#table-of-contents)\n- [Running Scripts from Anywhere](#running-scripts-from-anywhere)\n  - [Bin Executable](#bin-executable)\n  - [Symbolic Link](#symbolic-link)\n  - [Aliases](#aliases)\n  - [Extend Path](#extend-path)\n- [Script Configurations](#script-configurations)\n  - [Bash safe mode](#bash-safe-mode)\n  - [Bash configurations](#bash-configurations)\n- [Brace Expansion](#brace-expansion)\n- [Variable Expansion](#variable-expansion)\n  - [String interpolation](#string-interpolation)\n  - [Default values](#default-values)\n  - [Pattern matching](#pattern-matching)\n  - [Regex group pattern matching](#regex-group-pattern-matching)\n- [Arithmetic Expressions](#arithmetic-expressions)\n- [Compound Commands](#compound-commands)\n  - [Grouping Statements](#grouping-statements)\n  - [Sub Shells](#sub-shells)\n  - [Command Groups](#command-groups)\n- [Networks](#networks)\n  - [Ports](#ports)\n- [Nifty Terminal Commands](#nifty-terminal-commands)\n  - [Generate Timestamps](#generate-timestamps)\n  - [Set Operations](#set-operations)\n- [Miscellaneous](#miscellaneous)\n  - [Config Files](#config-files)\n  - [Colors](#colors)\n  - [Debugging Scripts](#debugging-scripts)\n\n## Running Scripts from Anywhere\n\nFirst you will need executable permission to run a script.\n\n```bash\n# Check to see what permissions files have.\nls -la\n\n# Grant user executable permission.\nsudo chmod u+x script.sh\n\n# Then run the script.\n./script.sh\n```\n\n### Bin Executable\nAdd the script to your local bin directory with executable permission.\n\n```bash\n# Usually bin executables do not have file extensions.\nsudo chmod u+x script\n\n# Copy file to user's local binaries folder.\nsudo cp script /usr/local/bin/\n```\n\n### Symbolic Link\nhttps://stackoverflow.com/questions/1951742/how-to-symlink-a-file-in-linux\n\n```bash\nsudo chmod u+x \u003cfile\u003e\n\n# Create a new symbolic link (will fail if already exist).\nsudo ln -s \u003cfile\u003e /usr/local/bin/\u003csymlink-name\u003e\n\n# Create or update symbolic link.\nsudo ln -sf \u003cfile\u003e /usr/local/bin/\u003csymlink-name\u003e\n\n# Example\nsudo ln -s /opt/android-studio/bin/studio.sh /usr/local/bin/android-studio\n\n# Example with cwd\nsudo ln -s \"$(cwd)/sherlock.py\" /usr/local/bin/sherlock\n```\n\n### Aliases\nYou can create an alias in your `.bashrc`\n\n```bash\nalias \u003calias-name\u003e='\u003cscript-path\u003e'\n```\n\n### Extend Path\n\nYou can also add any directory to be part of the bash executable path: `$PATH`\n\n```bash\n# Add the following line in your `.bash_profile`.\nexport PATH=\"\u003cmy-directory\u003e\":$PATH\n\n# Example\nexport PATH=\"~/Workspace/dotfiles/bin\":$PATH\n```\n\n\n## Script Configurations\nUse `set -o` to turn on a feature and `set +o` to turn it off.\n\n\n### Bash safe mode\n```bash\n# Enable bash safe mode.\nset -euo pipefail\n```\n\n```bash\n# Exit script if you try to use an uninitialized variable.\nset -o nounset\n\n# Exit script if a statement returns a non-true return value.\nset -o errexit\n\n# Use the error of the first failure rather than last error in pipe.\nset -o pipefail\n```\n\n### Bash configurations\n```bash\n# Export any variables that are defined.\nset -o allexport\n\n# Enable bash history.\nset -o history\n```\n\n## Brace Expansion\n- https://unix.stackexchange.com/questions/6035/when-do-you-use-brace-expansion\n\n```bash\n# Rename file (no spaces between commas).\nmv myfile.{js,jsx}\n\n# Create files with different extension.\ntouch myfile.{html,css,js,test.js,stories.js}\n\n# Show output of the cartesian product.\necho {a,b,c}/{1,2,3} | xargs -n1\necho {1..10}/{1..10} | xargs -n1\n\n# Create cartesian product of directories.\nmkdir -p ./{ComponentA,ComponentB}/{test,stories}\nmkdir -p ./{1..5}/{1..5}\n```\n\n## Variable Expansion\n- https://mywiki.wooledge.org/BashFAQ/100\n- http://tldp.org/LDP/abs/html/variable-expansion.html\n- https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html\n\n\n### String interpolation\n```bash\n# String interpolation with variables.\necho \"I want to eat $fruit\"\n\u003e I want to eat orange\n```\n\n### Default values\n```bash\n# Initialize variable with default value.\nfruit=${1:-'orange'}\necho \"I want to eat ${fruit}s\"\n\u003e I want to eat oranges\n```\n\n### Pattern matching\n```bash\n# Extracting user and repo using pattern matching from beginning (#).\nurl='https://github.com/codenameyau/intro-to-bash'\necho \"${url#*//*/}\"\n\u003e codenameyau/intro-to-bash\n\n# Extracting repo using greedy pattern matching from beginning (##).\nurl='https://github.com/codenameyau/intro-to-bash'\necho \"${url##*/}\"\n\u003e intro-to-bash\n\n# Extracting user profile using pattern matching from end (%).\nurl='https://github.com/codenameyau/intro-to-bash'\necho \"${url%/*}\"\n\u003e https://github.com/codenameyau\n\n# Extracting origin using pattern matching from end (%).\nurl='https://github.com/codenameyau/intro-to-bash'\necho \"${url%/*/*}\"\n\u003e https://github.com\n\n# Extracting protocol using greedy pattern matching from end (%%).\nurl='https://github.com/codenameyau/intro-to-bash'\necho \"${url%%://*}\"\n\u003e https\n```\n\n### Regex group pattern matching\n```bash\n# Capturing substring in regex group match.\nstring=\"origin  https://github.com/USERNAME/REPOSITORY.git (fetch)\"\n\n# Capture matched substring USERNAME\necho $(expr \"$string\" : .*github.com/'\\(.*\\)'/)\n\u003e USERNAME\n\n# Capture matched substring REPOSITORY\necho $(expr \"$string\" : .*/'\\(.*\\).git')\n\u003e REPOSITORY\n```\n\n## Arithmetic Expressions\n- Tutorial: https://mywiki.wooledge.org/ArithmeticExpression\n- Full reference: http://wiki.bash-hackers.org/syntax/arith_expr\n\n```bash\n# Wrap expression with double parens to specify math context.\necho $((1 + 1))\n\u003e 2\n\necho $((3 \u003c 2))\n\u003e 0\n\necho $((1 \u003c 2))\n\u003e 1\n\n# Using for loop. Spaces are allowed for assignment.\nfor ((i = 0; i \u003c 10; i++)); do echo \"$1\"; done\n```\n\n## Compound Commands\n- https://mywiki.wooledge.org/BashGuide/CompoundCommands\n- https://mywiki.wooledge.org/BashGuide/TestsAndConditionals#Grouping_Statements\n\n\n### Grouping Statements\nYou can use short circuiting with guard `\u0026\u0026` and\ndefault `||` statements for basic command grouping.\n\n```bash\n# Will exit the shell if cd exists.\ncd /tmp \u0026\u0026 exit 1\n\n# Will exit the shell if cd does not exist.\ncd /tmp || exit 1\n```\n\n### Sub Shells\nThis will launch the commands inside the parenthesis in subshell where variables have their own scope and will disappear once the command is complete or exits.\n\n```bash\n# The current directory $CWD variable will not be affected.\n(cd /tmp || exit 1; date \u003e timestamp)\n```\n\n### Command Groups\nYou can group commands with `{}` to run a series of commands whose\nfinal output could be used. This shares the same variables as the\ncurrent session.\n\n```bash\n{command_1; command_2; command_3} | command_4\n```\n\n## Networks\n\n### Ports\nRun this command kill a process running on specific port.\n```bash\nlsof -t -i :8000\n\nkill $(lsof -t -i :8000)\n```\n\nRun this command to see a list of open ports on a system.\n\n```bash\n# Show tcp, udp, listening ports, pid, numeric hosts, ipv4\nsudo netstat -tulpn4\n```\n\n## Nifty Terminal Commands\n\n### Generate Timestamps\nhttps://stackoverflow.com/questions/1204669/how-can-i-generate-unix-timestamps\n\n```bash\n# Timestamp: Thu Dec 28 10:44:45 EST 2017\ndate\n\n# Timestamp: 1514475851 (seconds)\ndate +%s\n\n# Timestamp: 1514476017560 (milliseconds)\ndate +%s%3N\n```\n\n### Set Operations\n\nThese operations must have files sorted first.\n\n```bash\n# Get lines common to both files.\ncomm -12 file1 file2\n\n# Read from std-in, sort, get lines in common, and copy to clipboard.\ncat | sort | comm -13 - s1 | pbcopy\n\n# Get lines only found in file1.\ncomm -23 file1 file2\n\n# Sort files as well.\ncomm -13 \u003c(sort file1) \u003c(sort file2)\ncomm -23 \u003c(sort file1) \u003c(sort file2)\n```\n\n### Rerunning commands\n\n```sh\n# Rerun the previous command with sudo.\nsudo !!\n\n# Rurun the previous command with substitutions.\n^before^after^\n```\n\n## Miscellaneous\n\n### Config Files\nYour program's configuration files are stored here. They are not removed by apt purge\nand may often contain unnecessary application data.\n```\ncd ~/./config\n```\n\n### Colors\nhttps://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux\n\n```bash\nBlack        0;30     Dark Gray     1;30\nRed          0;31     Light Red     1;31\nGreen        0;32     Light Green   1;32\nBrown/Orange 0;33     Yellow        1;33\nBlue         0;34     Light Blue    1;34\nPurple       0;35     Light Purple  1;35\nCyan         0;36     Light Cyan    1;36\nLight Gray   0;37     White         1;37\n```\n\n```bash\n# Reset colors\nColor_Off='\\033[0m'       # Text Reset\n\n# Regular colors\nBlack='\\033[0;30m'        # Black\nRed='\\033[0;31m'          # Red\nGreen='\\033[0;32m'        # Green\nYellow='\\033[0;33m'       # Yellow\nBlue='\\033[0;34m'         # Blue\nPurple='\\033[0;35m'       # Purple\nCyan='\\033[0;36m'         # Cyan\nWhite='\\033[0;37m'        # White\n\n# Bold\nBBlack='\\033[1;30m'       # Black\nBRed='\\033[1;31m'         # Red\nBGreen='\\033[1;32m'       # Green\nBYellow='\\033[1;33m'      # Yellow\nBBlue='\\033[1;34m'        # Blue\nBPurple='\\033[1;35m'      # Purple\nBCyan='\\033[1;36m'        # Cyan\nBWhite='\\033[1;37m'       # White\n\n# Underline\nUBlack='\\033[4;30m'       # Black\nURed='\\033[4;31m'         # Red\nUGreen='\\033[4;32m'       # Green\nUYellow='\\033[4;33m'      # Yellow\nUBlue='\\033[4;34m'        # Blue\nUPurple='\\033[4;35m'      # Purple\nUCyan='\\033[4;36m'        # Cyan\nUWhite='\\033[4;37m'       # White\n```\n\n### Debugging Scripts\n- [Guide to bash debugging](https://mywiki.wooledge.org/BashGuide/Practices#Debugging)\n- [Always quote variables](https://mywiki.wooledge.org/BashGuide/Practices#Quoting)\n\n**Method 1:** Run your script with the `-x` flag.\n```bash\n$ bash -x myscript.sh\n```\n\n**Method 2:** Modify the script's interpreter directive to include the `-x` flag.\n```bash\n#!/bin/bash -x\n```\n\n**Method 3:** Selectively debug sections of code.\n```bash\n#!/bin/bash\n\n# Turn on debugging.\nset -x\n\n# Turn off debugging.\nset +x\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodenameyau%2Fdotfiles","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodenameyau%2Fdotfiles","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodenameyau%2Fdotfiles/lists"}