- This repository has all of my "admistrative" programs that I used in various other repo's
- It has my hooks, scripts, workflow, and other important programs
- It has my notes on how to use each, where I found then, what I changed, and how to integrate them into my IDE
install
pip install blackblack script
#!/usr/bin/env bash
# This script is used to format the code using black.
# Exit immediately if a command exits with a non-zero status.
set -e
# Change to the root directory of the project.
cd "$(dirname "$0")/.."
# Format the code.
black .add permissions to script
chmod +x <FILE_NAME>configuration https://clang.llvm.org/docs/ClangFormat.html
install
brew install clang-formatI no longer have it in the pre-commit hook but instead can be run standalone
bash ~/Dropbox/Programming/dotfiles/scripts/clang.bashhow to execute
clang-format -i <FILE_NAME>script code
read varfilename
cd ~/Dropbox/Programming/Java/src
chmod +x $varfilename
touch temp.txt
clang-format -style=file $varfilename > temp.txt
truncate -s 0 $varfilename
cat temp.txt >> $varfilename
rm temp.txt
chmod -x $varfilenamesecondary script code
#!/usr/bin/env bash
# This script is used to format the code using clang-format.
# Exit immediately if a command exits with a non-zero status.
set -e
# Change to the root directory of the project.
cd "$(dirname "$0")/.."
# Format the code.
clang-format -i ~/Dropbox/Programming/Java/src/*.javaadd permissions to script
chmod +x <FILE_NAME>github https://github.com/dannysepler/rm_unneeded_f_str
install
pip install rm_unneeded_f_strgithub https://github.com/codespell-project/codespell
configuration https://calmcode.io/pre-commit/spelling.html
install
pip install codespelluse
codespell <FILE_NAME>find error and change
codespell -w <FILE_NAME>normal commang
codespell --skip '*.git' -w *.py *.md *.txt *.javascript
#!/usr/bin/env bash
# This script is used to check the code for spelling errors using codespell.
# Exit immediately if a command exits with a non-zero status.
set -e
# Change to the root directory of the project.
cd "$(dirname "$0")/.."
# Check the code for spelling errors.
codespell --skip '*.git' -w src/*.py src/*.md src/*.txt src/*.javaadd permissions
chmod +x codespell.bashinstall instructions https://flake8.pycqa.org/en/latest/user/configuration.html
Rules https://www.flake8rules.com
install
brew install flake8add configuration file
touch .flake8add to configuration file
cat ~/Dropbox/Programming/dotfiles/templates/flake8.txt >> .flake8flake8 script
#!/usr/bin/env bash
# This script is used to format the code using flake8.
# Exit immediately if a command exits with a non-zero status.
set -e
# Change to the root directory of the project.
cd "$(dirname "$0")/.."
# Format the code.
flake8 .add permissions to script
chmod +x <FILE_NAME>install instructions https://beta.ruff.rs/docs/tutorial/
Configure page https://beta.ruff.rs/docs/configuration/
Install
pip install ruffadd configuration file
touch pyproject.tomladd to configuration file
cat ~/Dropbox/Programming/dotfiles/templates/ruff.txt >> pyproject.tomlrun ruff
ruff <FILE_NAME>fix some errors
ruff <FILE_NAME> --fixruff script
#!/usr/bin/env bash
# This script is used to format the code using ruff.
# Exit immediately if a command exits with a non-zero status.
set -e
# Change to the root directory of the project.
cd "$(dirname "$0")/.."
# Format the code.
ruff .add permissions to script
chmod +x <FILE_NAME>https://pre-commit.com https://pre-commit.com/hooks.html
brew install pre-commit
python3 -m pip install -U mypymkdir workflows
cd ./workflows
touch .pre-commit-config.yaml
cat ~/Dropbox/Programming/dotfiles/templates/.pre-commit-config.txt >> .pre-commit-config.yaml
chmod +x .pre-commit-config.yaml
cd ..cd .git/hooks
mv pre-commit.sample pre-commit
truncate -s 0 pre-commit
cat ~/Dropbox/Programming/dotfiles/templates/pre-commit.txt >> pre-commit
chmod +x pre-commit
xattr -d com.apple.quarantine pre-commit
cd ../..cd .git/hooks
mv pre-commit pre-commit.sample
cd ../..
rmdir -r workflowscd workflows/
pre-commit autoupdate --bleeding-edge- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: name-tests-test
- id: mixed-line-ending
- id: check-ast
- id: check-case-conflict
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
- id: pyupgrade
You have to add fail_fast: false one the top line before the first repo:
- repo: https://github.com/pocc/pre-commit-hooks
rev: master
hooks:
- id: clang-format
args: [-i]
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.260'
hooks:
- id: ruff
- repo: https://github.com/codespell-project/codespell
rev: v1.16.0
hooks:
- id: codespell
name: codespell
description: Checks for common misspellings in text files.
entry: codespell --skip '*.git' -w *.py *.md *.txt *.java
language: python
types: [text]
- repo: https://github.com/dannysepler/rm_unneeded_f_str
rev: v0.2.0
hooks:
- id: rm-unneeded-f-str
You can automate all of these with the scripts and file watching
- Go to setting in the IDE
- Find 'File Watchers'
- Click the '+' button
- Hit 'custom'
- Name it the name of the script
- Change file type to intended file type (Any, java, python)
- Change scope to 'All Changed Files'
- Add the script under 'Program'
- Click 'OK'
Now it will run those scripts when you don't touch the keyboard for more than 2 seconds