fm is a CLI tool currently in early development, designed to format scripts across various projects. This tool offers more control over formatting compared to relying on an IDE. While it's still in development, it's fully usable! If you're interested in contributing, feel free to fork the repo and submit a PR.
- shfmt
- black
- prettier
- clang-format
- gofmt (included with Go)
- rustfmt (installed with Rustup)
- swift-format
The install.sh script will attempt to install these for you using your system's package manager. If fm is already installed, running install.sh will update your existing dependencies instead.
- macOS (Homebrew)
- Debian/Ubuntu (APT)
- RHEL/CentOS (YUM)
- Fedora (DNF)
- openSUSE (Zypper)
- Arch Linux (Pacman)
- Gentoo (Portage)
- Void Linux (XBPS)
- Android/Termux (pkg)
NOTE: On macOS, GNU getopt is required and will be installed automatically. The script will auto-detect Homebrew's installation, so no manual PATH configuration is needed in most cases.
.py
.sh
.bash
.dash
.ksh
.zsh
.js
.jsx
.ts
.tsx
.json
.md
.yml
.yaml
.graphql
.vue
.scss
.less
.c
.cpp
.h
.hpp
.m
.mm
.java
.go
.rs
.swiftThere is consideration for supporting additional languages based on community demand. The formatters that are being heavily considered right now are the following:
- Ruby (rubocop)
- PHP (PHP-CS-Fixer)
- C# (Csharpier)
Support for formatting HTML and CSS files was heavily considered, but no suitable solution exists that meets the project's standards. So, sadly, support for HTML and CSS will not happen any time soon.
# clone the repository and navigate into it
git clone https://github.com/MehmetMHY/fm.git && cd fm
# run the install script (or update dependencies if already installed)
bash install.shThis is optional, but for a more controlled installation or update where you're prompted for each dependency:
bash install.sh -wOr using the long form:
bash install.sh --wizardThis is optional, but if you want to remove fm from your system:
bash uninstall.shTo see all options, use the help flag:
fm -hTo format an entire directory:
fm /path/to/dirTo format a single file:
fm path/to/filenameFormat current directory by default:
fmYou can specify which languages to format using the -l or --languages flag. Provide a comma-separated list of languages.
Available languages: bash, python, javascript, clang, go, rust, swift.
# format only Python and Bash files in the current directory
fm -l 'python,bash' .You can ignore specific files or directories using the -I or --ignore flag. You can use this flag multiple times. It accepts glob patterns.
# ignore the node_modules and dist directories
fm -I 'node_modules/*' -I 'dist/*' .
# ignore all .log files
fm --ignore '*.log' .To see which files would be changed without actually modifying them, use the --check or -c flag. This is useful for CI checks or pre-commit hooks.
# check for files that need formatting
fm --check .To speed up formatting on large projects, you can run the formatter on multiple files in parallel using the --workers or -w flag.
# run with 4 parallel workers
fm --workers 4 .To format files that are listed in your .gitignore file, use the --no-gitignore flag.
# format all files, including those in .gitignore
fm --no-gitignore .This project is licensed under the GNU General Public License v3.0.