-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
225 additions
and
167 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,58 @@ | ||
{ | ||
"image" : "mcr.microsoft.com/devcontainers/base:jammy", | ||
"postCreateCommand": "curl -fsSL https://raw.githubusercontent.com/gvatsal60/Linux-Aliases/HEAD/main.sh | sh", | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"streetsidesoftware.code-spell-checker", | ||
"esbenp.prettier-vscode", | ||
"Gruntfuggly.todo-tree", | ||
"DavidAnson.vscode-markdownlint", | ||
"bierner.markdown-emoji", | ||
"timonwong.shellcheck", | ||
"foxundermoon.shell-format" | ||
] | ||
} | ||
"capAdd": [ | ||
"SYS_PTRACE" | ||
], | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"streetsidesoftware.code-spell-checker", | ||
"esbenp.prettier-vscode", | ||
"Gruntfuggly.todo-tree", | ||
"DavidAnson.vscode-markdownlint", | ||
"MindpathTechnologyLimited.code-error-lens", | ||
"gurumukhi.selected-lines-count", | ||
"bradzacher.vscode-copy-filename", | ||
"PKief.material-icon-theme", | ||
"timonwong.shellcheck", | ||
"foxundermoon.shell-format" | ||
], | ||
"settings": { | ||
"editor.bracketPairColorization.enabled": true, | ||
"editor.comments.insertSpace": true, | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"editor.detectIndentation": false, | ||
"editor.insertSpaces": true, | ||
"editor.tabCompletion": "on", | ||
"editor.tabSize": 2, | ||
"editor.trimAutoWhitespace": true, | ||
"explorer.confirmDelete": false, | ||
"extensions.autoUpdate": true, | ||
"extensions.ignoreRecommendations": true, | ||
"files.autoSave": "afterDelay", | ||
"files.eol": "auto", | ||
"files.exclude": { | ||
"**/.vscode": true | ||
}, | ||
"search.exclude": { | ||
"**/*.code-search": true, | ||
"**/*.git": true, | ||
"**/*.vscode-server": true, | ||
"**/bower_components": true, | ||
"**/node_modules": true | ||
}, | ||
"windows.title": "${folderPath}", | ||
"workbench.iconTheme": "material-icon-theme", | ||
"workbench.startupEditor": "none" | ||
} | ||
} | ||
} | ||
}, | ||
"image": "mcr.microsoft.com/devcontainers/base:jammy", | ||
"mounts": [ | ||
"source=${localWorkspaceFolder}/snippets,target=${containerWorkspaceFolder}/.vscode,type=bind" | ||
], | ||
"postCreateCommand": "curl -fsSL https://raw.githubusercontent.com/gvatsal60/Linux-Aliases/HEAD/install.sh | sh", | ||
"runArgs": [ | ||
"--rm", | ||
"--name=vsc-${localEnv:USER}-${containerWorkspaceFolderBasename}-${devcontainerId}" | ||
] | ||
} |
File renamed without changes.
8 changes: 0 additions & 8 deletions
8
.github/workflows/ShellCheck.yml → .github/workflows/ShellCheck.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,32 @@ | ||
name: ShellCheck | ||
|
||
on: | ||
pull_request: | ||
branches: ["*"] | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
shellcheck: | ||
name: ShellCheck | ||
runs-on: ubuntu-latest | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install ShellCheck | ||
run: sudo apt update && sudo apt install shellcheck -y | ||
|
||
- name: Run ShellCheck | ||
run: | | ||
shellcheck *.sh | ||
if [ $? -ne 0 ]; then | ||
echo "ShellCheck Detected Errors!!!" | ||
exit 1 | ||
fi | ||
- name: Install shfmt | ||
run: | | ||
sudo apt install shfmt -y | ||
- name: Format Shell Scripts | ||
run: | | ||
find . -name "*.sh" -exec shfmt -w -i 2 {} \; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
.github/workflows/readme-checker.yml → .github/workflows/readme-checker.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
MD013: | ||
line_length: 100 | ||
line_length: 999 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,62 @@ | ||
repos: | ||
# Syncs pre-commit dependencies with the latest versions. | ||
- repo: https://github.com/mxr/sync-pre-commit-deps | ||
rev: "v0.0.1" | ||
hooks: | ||
- id: sync-pre-commit-deps | ||
# Pre-commit hooks for general file checks | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: "v4.6.0" | ||
hooks: | ||
- id: check-added-large-files | ||
- id: check-ast | ||
- id: check-builtin-literals | ||
- id: check-case-conflict | ||
- id: check-docstring-first | ||
- id: check-executables-have-shebangs | ||
- id: check-json | ||
- id: check-merge-conflict | ||
- id: check-shebang-scripts-are-executable | ||
- id: check-symlinks | ||
- id: check-toml | ||
- id: check-vcs-permalinks | ||
- id: check-xml | ||
- id: check-yaml | ||
- id: debug-statements | ||
- id: destroyed-symlinks | ||
- id: double-quote-string-fixer | ||
- id: end-of-file-fixer | ||
- id: fix-byte-order-marker | ||
- id: mixed-line-ending | ||
- id: name-tests-test | ||
- id: pretty-format-json | ||
args: [--autofix, --no-ensure-ascii, --no-sort-keys] | ||
- id: requirements-txt-fixer | ||
- id: trailing-whitespace | ||
# ShellCheck hook for linting shell scripts | ||
- repo: https://github.com/shellcheck-py/shellcheck-py | ||
rev: v0.10.0.1 | ||
rev: "v0.10.0.1" | ||
hooks: | ||
- id: shellcheck | ||
name: shellcheck | ||
description: This hook runs shellcheck for linting shell scripts | ||
|
||
# Bashate hook for linting shell scripts | ||
- repo: https://github.com/openstack/bashate | ||
rev: 2.1.1 | ||
rev: "2.1.1" | ||
hooks: | ||
- id: bashate | ||
name: bashate | ||
description: This hook runs bashate for linting shell scripts | ||
entry: bashate | ||
language: python | ||
types: [shell] | ||
# Yamlfmt for formatting YAML files | ||
- repo: https://github.com/google/yamlfmt | ||
rev: "v0.13.0" | ||
hooks: | ||
- id: yamlfmt | ||
# Codespell for detecting common misspellings in code | ||
- repo: https://github.com/codespell-project/codespell | ||
rev: "v2.3.0" | ||
hooks: | ||
- id: codespell |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
#!/bin/sh | ||
|
||
########################################################################################## | ||
# File: install.sh | ||
# Author: Vatsal Gupta | ||
# Date: 12-Jul-2024 | ||
# Description: Setup of custom aliases on a Linux system by downloading a | ||
# predefined .aliases.sh file from a GitHub repository and | ||
# integrating it into the user's shell configuration | ||
# files (~/.bashrc, ~/.zshrc, or ~/.profile) | ||
########################################################################################## | ||
|
||
########################################################################################## | ||
# License | ||
########################################################################################## | ||
# This script is licensed under the Apache 2.0 License. | ||
|
||
########################################################################################## | ||
# Global Variables & Constants | ||
########################################################################################## | ||
readonly FILE_NAME=".aliases.sh" | ||
readonly FILE_LINK="https://raw.githubusercontent.com/gvatsal60/Linux-Aliases/HEAD/${FILE_NAME}" | ||
|
||
UPDATE_RC="${UPDATE_RC:-"true"}" | ||
|
||
########################################################################################## | ||
# Functions | ||
########################################################################################## | ||
# Function: updaterc | ||
# Description: Update shell configuration files | ||
updaterc() { | ||
_rc="" | ||
if [ "${UPDATE_RC}" = "true" ]; then | ||
case $ADJUSTED_ID in | ||
debian | rhel) | ||
_rc=~/.bashrc | ||
;; | ||
alpine | arch) | ||
_rc=~/.profile | ||
;; | ||
*) | ||
echo "Error: Unsupported or unrecognized Linux distribution ${ADJUSTED_ID}" | ||
exit 1 | ||
;; | ||
esac | ||
|
||
# Check if . "${HOME}/.aliases.sh" is already defined, if not then append it | ||
if [ -f "${_rc}" ]; then | ||
if ! grep -qxF ". \"\${HOME}/${FILE_NAME}\"" "${_rc}"; then | ||
echo "Updating ${_rc} for ${ADJUSTED_ID}..." | ||
printf "\n# Sourcing custom aliases\n. \"%s/%s\"\n" "$HOME" "$FILE_NAME" >> "${_rc}" | ||
fi | ||
else | ||
echo "Error: File ${_rc} does not exist." | ||
echo "Creating the ${_rc} file... although not sure if it will work." | ||
touch ${_rc} | ||
printf "\n# Sourcing custom aliases\n. \"%s/%s\"\n" "$HOME" "$FILE_NAME" >> "${_rc}" | ||
fi | ||
fi | ||
} | ||
|
||
# Function: dw_file | ||
# Description: Download file using wget or curl if available | ||
dw_file() { | ||
# Check if wget is available | ||
if command -v wget >/dev/null 2>&1; then | ||
wget -O "${HOME}/${FILE_NAME}" ${FILE_LINK} | ||
# Check if curl is available | ||
elif command -v curl >/dev/null 2>&1; then | ||
curl -fsSL -o "${HOME}/${FILE_NAME}" ${FILE_LINK} | ||
else | ||
echo "Error: Either install wget or curl" | ||
exit 1 | ||
fi | ||
} | ||
|
||
########################################################################################## | ||
# Main Script | ||
########################################################################################## | ||
|
||
# Bring in ID, ID_LIKE, VERSION_ID, VERSION_CODENAME | ||
# shellcheck source=/dev/null | ||
. /etc/os-release | ||
|
||
# Get an adjusted ID independent of distro variants | ||
if [ "${ID}" = "debian" ] || [ "${ID_LIKE}" = "debian" ]; then | ||
ADJUSTED_ID="debian" | ||
elif [ "${ID}" = "alpine" ]; then | ||
ADJUSTED_ID="alpine" | ||
elif [ "${ID}" = "arch" ] || [ "${ID_LIKE}" = "arch" ] || (echo "${ID_LIKE}" | grep -q "arch"); then | ||
ADJUSTED_ID="arch" | ||
elif [ "${ID}" = "rhel" ] || [ "${ID}" = "fedora" ] || [ "${ID}" = "mariner" ] || (echo "${ID_LIKE}" | grep -q "rhel") || (echo "${ID_LIKE}" | grep -q "fedora") || (echo "${ID_LIKE}" | grep -q "mariner"); then | ||
ADJUSTED_ID="rhel" | ||
else | ||
echo "Error: Linux distro ${ID} not supported." | ||
exit 1 | ||
fi | ||
|
||
if [ -f "${HOME}/${FILE_NAME}" ]; then | ||
echo "File already exists: $HOME/${FILE_NAME}" | ||
echo "Do you want to replace it (default: y)? [y/n]: " | ||
read -r rp_conf | ||
rp_conf="${rp_conf:-y}" | ||
if [ "$rp_conf" = "y" ]; then | ||
# Replace the existing file | ||
echo "Replacing $HOME/${FILE_NAME}..." | ||
dw_file | ||
updaterc | ||
else | ||
echo "Keeping existing file: $HOME/${FILE_NAME}" | ||
fi | ||
else | ||
dw_file | ||
updaterc | ||
fi |
Oops, something went wrong.