GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
PORTFMT(1) FreeBSD General Commands Manual PORTFMT(1)

portfmt
format FreeBSD Ports Collection Makefiles

portfmt [-D[context]] [-ditu] [-w wrapcol] [Makefile]

portfmt is a tool for formatting FreeBSD Ports Collection Makefiles.

If the optional Makefile argument is not given, the Makefile will be read from stdin. This can be useful for editor integration where you might want to only format portions of your Makefile.

The following options are available:

[context]
Output a unified diff from the original to the formatted version. This can optionally be followed by the number of context lines. It defaults to 3 lines of context. For full context use 0.
Dump the AST to stdout. This is only useful for debugging purposes. If this flag is specified -i is ignored.
Format Makefile in-place instead of writing the result to stdout.
Format and reindent target commands.
Leave variables unsorted.
Always sort variables.
wrapcol
Sets the wrapping column to wrapcol (default: 80). This is a goal not a hard value. It will be ignored for several variables like COMMENT, DISTFILES, MASTER_SITES, etc.

With a value of -1 it is ignored for all variables. Variables with wrapped tokens over multiple lines will be concatenated onto a single line.

You can integrate Portfmt into your editor to conveniently run it only on parts of the port, e.g., to reformat USES after adding a new item to it.

Add this to ~/.emacs.d/init.el to format the current region with C-c p:
(defun portfmt (&optional b e)
  "PORTFMT(1) on region"
  (interactive "r")
  (shell-command-on-region b e "portfmt " (current-buffer) t
                           "*portfmt errors*" t))
(with-eval-after-load 'make-mode
  (define-key makefile-bsdmake-mode-map (kbd "C-c p") 'portfmt))

Add this to ~/.config/kak/kakrc for filtering the current selection through portfmt with ,1:
map global user 1 '|portfmt<ret>;' \
	-docstring "portfmt on selection"

Add this to ~/.vimrc for filtering the current selection through portfmt with \1:
xnoremap <leader>1 <esc>:'<,'>!portfmt<CR>

The following environment variables affect the execution of portfmt:
If defined portfmt will output text with ANSI colors even when stdout is not a tty or NO_COLOR is set.
If defined colors will be disabled.

portfmt will exit with one of the following values:
0
Success.
1
An error occurred.
2
There were changes when compared to the original file. Only possible with -D.

In-place format /usr/ports/audio/sndio/Makefile:
portfmt -i /usr/ports/audio/sndio/Makefile

ports(7)

Tobias Kortkamp <tobik@FreeBSD.org>
September 19, 2021 FreeBSD 13.1-RELEASE

Search for    or go to Top of page |  Section 1 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.