Skip to content
ilya-bystrovPublic

About

A minimal POSIX shell tool for centralizing configuration and generating target-specific output for .profile, .bashrc, or any text consumer

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Poljot

Poljot is a shell configuration manager that proposes organizing related settings around use cases. It keeps configuration in one tree and emits the output needed by a requested target.

Use cases are an organizational approach, not a requirement. A configuration can group settings by any logic and target .profile, .bashrc, or any other file that consumes the generated output. The implementation is deliberately small: it provides targeted sections and text output. Every *.conf file can group related settings for one or more targets.

Status

Poljot is a small tool with a deliberately focused implementation. It reads target sections and writes their contents to standard output. Further additions can focus on automated tests and distributable packages without changing this core behavior. When the output is used as shell code, review configuration files before enabling them in a shell startup file.

Usage

Add one sourcing line to each startup file that should receive configuration. For .profile, use the POSIX-compatible form:

# ~/.profile
eval "$(poljot .profile)"

For Bash .bashrc, use process substitution:

# ~/.bashrc
. <(poljot .bashrc)

Target names are written after the poljot: prefix. They can refer to any target that consumes generated output:

eval "$(poljot target-name)"

The process-substitution form requires Bash or another compatible shell. See Shell Compatibility for distribution-specific shell and process-substitution details.

Configuration

A configuration file can group related startup instructions:

[poljot:.profile]
export EDITOR=vi
export PAGER=less
export PATH="$HOME/bin:$PATH"

[poljot:.bashrc]
alias ll='ls -alF'
alias gs='git status'

. /etc/bash_completion
. "$HOME/.config/my-shell/aliases.sh"

The target section is copied as-is. This is the place for shell syntax, including comments, variable expansion, source commands, conditionals, aliases, and functions.

How It Works

poljot TARGET reads these files in order:

  1. ${HOME}/.config/poljot/poljot.conf
  2. Every matching ${HOME}/.config/poljot/conf.d/*.conf file, in lexical filename order

Neither configuration source is required.

For each file, Poljot selects sections whose target exactly matches TARGET. The supported section form is:

[poljot:TARGET]
Prints each following line unchanged until another section starts.

Sections for other targets are ignored. The generated output can be consumed by the target file or process that requested it.

Configuration Files

The main configuration file and additional configuration files can be organized like this:

~/.config/poljot/poljot.conf
~/.config/poljot/conf.d/20-sdkman.conf
~/.config/poljot/conf.d/60-environment.conf
~/.config/poljot/conf.d/70-aliases.conf

All additional configuration files are processed after poljot.conf and sorted by their filenames. If multiple matching sections emit the same setting, the resulting shell code follows that order, so later commands can override earlier ones.

Installation

Poljot is distributed as a single POSIX shell script. Place poljot on your PATH and make sure it is executable. For a user-local installation, run:

$ install -m 0755 poljot "$HOME/.local/bin/poljot"

For a system-wide installation, install it into /usr/local/bin as root:

# install -m 0755 poljot /usr/local/bin/poljot

The destination directory must already exist and be included in PATH. No installer or package release is provided yet.

Dependencies

Runtime dependencies are:

  • a POSIX-compatible sh

The Bash process-substitution integration requires Bash or another compatible shell. The command-substitution and eval integration works with POSIX shells and does not require Bash.

Shell Compatibility

The poljot program is written for a POSIX-compatible sh. The distribution default for /bin/sh determines whether the process-substitution example is available:

Typical Linux shell defaults
Distribution family Typical /bin/sh Version family Process substitution
Debian, Ubuntu, Linux Mint dash 0.5.x Not supported by default
Fedora bash 5.x Supported
RHEL and CentOS Stream bash 4.x or 5.x Supported
Arch Linux bash 5.x Supported
openSUSE bash 5.x Supported
Alpine Linux BusyBox ash 1.3x Not supported by default

The exact shell version depends on the distribution release and installed packages. POSIX does not define process substitution. Use the command-substitution and eval form above when /bin/sh is dash, BusyBox ash, or another shell without process substitution. Both forms execute the generated code in the current shell, which allows variables, aliases, and functions to persist in the startup shell.

The active sh implementation can be inspected with:

$ readlink -f /bin/sh
/usr/bin/dash

Process-substitution support can be tested with:

$ /bin/sh -c 'cat <(printf x)' >/dev/null 2>&1 && echo supported || echo unsupported

Debugging

Set POLJOT_DEBUG=1 to include the source configuration filename in the generated output:

$ POLJOT_DEBUG=1 poljot .bashrc

The command writes generated output to standard output. Usage errors, such as omitting the target, are written to standard error.

Missing or unreadable configuration files and sections for other targets are silently ignored. Debug mode shows readable configuration files being processed, but it does not validate section syntax or report skipped entries.

License

Poljot is distributed under the MIT License. See LICENSE.

About

A minimal POSIX shell tool for centralizing configuration and generating target-specific output for .profile, .bashrc, or any text consumer

Resources

Stars

0 stars

Watchers

0 watching

Forks

Packages

Contributors

Languages