Giter Site home page Giter Site logo

penv's Introduction

PENV

This is a simple C++ program that prints out certain critical environment variables in a formatted way.

Features:

  • Retrieves environment variables using the env command.
  • Parses the output of the env command and extracts relevant information.
  • Displays a formatted list of environment variables.
  • Includes formatting labels for specific variables, improving readability.

Prerequisites:

  • C++17 or later: The code utilizes modern C++ features like std::format.
  • smart_view_vector: This header file is part of the experimental C++29 standard. You can find it in the CXX29 / C++ 29 repository.
  • env command available (part of most Unix-like systems)

How to Compile and Run:

  1. Install the smart_view_vector header file:
    • Download the header file from the TaiHusk/CXX29 repository.
    • Place the header file in your project directory or include it in your compiler's include path.
  2. Compile the code:
    g++ -o runner -std=c++20 ./src/main.cpp
  3. Run the executable:
    ./runner

Output:

The program will display a formatted list of critical environment variables, such as:

host type: Linux
user: your_username
home: /home/your_username
color term: xterm-256color
name: your_computer_name
term: xterm
language: en_US.UTF-8
shell: /bin/bash
pwd: /home/your_username
wayland display: wayland-0
XDG_RUNTIME_DIR: /run/user/1000
XDG_DATA_DIRS: /usr/local/share:/usr/share

Dependencies

This program uses the following dependencies:

  • <cstdio>: For file operations (popen, pclose, FILE, etc.)
  • <iostream>: For standard input/output streams (std::cout, std::endl, etc.)
  • <sstream>: For string stream operations (std::stringstream)
  • <string>: For string manipulation (std::string)
  • <vector>: For dynamic array operations (std::vector)
  • <format>: For string formatting (std::format)
  • <c++/29/experimental/smart_view_vector>: For the smart_view_vector::includes function (from the C++29 experimental std)

Customization:

  • Modify the criticality_name vector: Add or remove environment variables to customize the output.
  • Add or change formatting labels in the format_label vector: Improve the readability of the output.

Note:

  • The program uses the popen function to execute the env command. This function may not be available on all platforms.
  • The output may vary depending on your system configuration.
  • The program uses the smart_view_vector class from the C++29 standard library, which is part of the experimental features. This may not be available on all platforms.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.