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)
The install.sh
script will attempt to install these for you using your system's package manager.
- macOS (Homebrew)
- Debian/Ubuntu (APT)
- RHEL/CentOS (YUM)
- Fedora (DNF)
- openSUSE (Zypper)
- Arch Linux (Pacman)
- Gentoo (Portage)
- Void Linux (XBPS)
- Android/Termux (pkg)
Note for macOS: GNU getopt
is required and will be installed automatically. Add export PATH="$(brew --prefix gnu-getopt)/bin:$PATH"
to your shell profile if needed.
.py
.sh
.bash
.dash
.ksh
.js
.jsx
.ts
.tsx
.json
.md
.html
.css
.yml
.yaml
.graphql
.vue
.scss
.less
.c
.cpp
.h
.hpp
.m
.mm
.java
.go
-
Clone the repository and go into it:
git clone https://github.com/MehmetMHY/fm.git ; cd fm
-
Run the install script to install and/or update fm:
bash install.sh
-
(optional) Uninstall fm, if you desire, by running the uninstall script:
bash uninstall.sh
To see all options, use the help flag:
fm -h
To format an entire directory:
fm /path/to/dir
To format a single file:
fm path/to/filename
Format current directory by default:
fm
You 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
.
# 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 .
For more control, you can use interactive mode with --interactive
or -i
. The script will prompt you for each file before formatting.
# run in interactive mode
fm -i .
You will be prompted with [y]es, [N]o, [a]ll, [q]uit
.
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 .