···11+# NX - Nginx Site Manager
22+33+A lightweight, colorized Bash utility to manage Nginx virtual hosts using the sites-available / sites-enabled pattern. It replaces the need for manual ln -s and rm commands with a simple, human-readable interface.
44+55+## Features
66+77+* Tree-view Listing: Automatically groups subdomains under their parent domains using ASCII logic.
88+* Status Indicators: Color-coded feedback for "Enabled" (Green) and "Disabled" sites.
99+* Smart Suffixes: Automatically handles .conf extensions so you don't have to type them.
1010+* Integrated Testing: Prompts to run nginx -t and reload the service after every edit or toggle.
1111+* Config Preview: Uses batcat (with syntax highlighting) if installed, otherwise falls back to cat.
1212+1313+## Installation
1414+1515+To install nx system-wide while keeping the source code in this repository for easy updates:
1616+1717+1. Move the repository to a permanent location:
1818+ mkdir -p ~/projects
1919+ mv nx-manager ~/projects/
2020+ cd ~/projects/nx-manager
2121+2222+2. Make the script executable:
2323+ chmod +x nx
2424+2525+3. Create a symbolic link in your PATH:
2626+ sudo ln -s $(pwd)/nx /usr/local/bin/nx
2727+2828+## Usage
2929+3030+Most commands require sudo to modify Nginx directories and reload the service.
3131+3232+- List sites: sudo nx list (or nx l)
3333+- Enable site: sudo nx enable mydomain.com
3434+- Disable site: sudo nx disable mydomain.com
3535+- Edit config: sudo nx e mydomain.com
3636+- Print config: nx p mydomain.com
3737+3838+## Environment Variables
3939+4040+The edit command respects your preferred editor. You can set this in your ~/.bashrc or ~/.zshrc:
4141+4242+export EDITOR='emacs'
4343+4444+Note: To ensure your personal $EDITOR setting is picked up when running with sudo, use the -E flag:
4545+sudo -E nx e mydomain.com
4646+4747+## License
4848+4949+MIT