{"id":15113851,"url":"https://github.com/hussein-m-kandil/pathvar","last_synced_at":"2026-01-18T23:01:57.728Z","repository":{"id":166580491,"uuid":"641937189","full_name":"hussein-m-kandil/pathvar","owner":"hussein-m-kandil","description":"My final project for CS50p, a command line utility for interacting and manipulating the system's PATH environment variable (Linux BASH only)","archived":false,"fork":false,"pushed_at":"2024-01-11T06:28:27.000Z","size":146,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-25T00:37:03.142Z","etag":null,"topics":["bash","bash-script","command-line","command-line-tool","environment-variables","environment-variables-validation","linux","linux-app","linux-shell","path","pyth","python3","shell","shell-script","shell-scripting","unix","unix-shell"],"latest_commit_sha":null,"homepage":"https://pypi.org/p/pathvar","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hussein-m-kandil.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-05-17T13:27:30.000Z","updated_at":"2024-09-22T10:48:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"37443ddd-bd6d-4c45-af72-75907cd9b6f7","html_url":"https://github.com/hussein-m-kandil/pathvar","commit_stats":{"total_commits":18,"total_committers":2,"mean_commits":9.0,"dds":0.05555555555555558,"last_synced_commit":"5320e6b901b6b56507d75a9735fb6b7b6e52d1c1"},"previous_names":["hussein-m-kandil/pathvar"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/hussein-m-kandil/pathvar","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hussein-m-kandil%2Fpathvar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hussein-m-kandil%2Fpathvar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hussein-m-kandil%2Fpathvar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hussein-m-kandil%2Fpathvar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hussein-m-kandil","download_url":"https://codeload.github.com/hussein-m-kandil/pathvar/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hussein-m-kandil%2Fpathvar/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28553055,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T20:59:07.572Z","status":"ssl_error","status_checked_at":"2026-01-18T20:59:02.799Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","bash-script","command-line","command-line-tool","environment-variables","environment-variables-validation","linux","linux-app","linux-shell","path","pyth","python3","shell","shell-script","shell-scripting","unix","unix-shell"],"created_at":"2024-09-26T01:23:32.583Z","updated_at":"2026-01-18T23:01:57.700Z","avatar_url":"https://github.com/hussein-m-kandil.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pathvar\n\n### Video Demo: https://youtu.be/THzJUZlqiI0x\n\n### Description:\n\nMy final project for **CS50P**: \"_CS50 Introduction to Programming with Python_\".\n\n![Screenshot of the help output.](./assets/images/pathvar_screen.png)\n\nThis tool meant to facilitate the interaction with the system PATH environment variable (Linux BASH shell only).\n\n- To get the work done correctly do the following:\n  - Read the 'help' instruction well\n  - Be careful about the paths you input (with some options)\n  - Separate between multiple paths with a single colon ':'\n\nNOTE: This program saves the new modified PATH value in '~/.bash_profile' file,\nand if this file not exists creates a new one,\nand eventually source the '~/.bashrc' and '~/.profile' if any of them exists.\n\n---\n\n### Usage:\n\n    project.py [-h] [-s] [-e] [-a] [-p] [-d] [-q] [--remove-all-paths] [-v]\n\n### Options:\n\n- **_-h, --help_**\n  - show this help message and exit\n- **_-s, --show_**\n  - shows the current value of the 'PATH' (default)\n- **_-e, --eliminate-duplicates_**\n  - eliminates any duplicates in the value of the 'PATH' (Included with any modifications)\n- **_-a , --append_**\n  - appends any number of paths to the current value of the 'PATH' (which are must be given as a\n    single string separated with ':' between every two paths and without any spaces)\n- **_-p , --push_**\n  - pushes any number of paths at the beginning of the current value of 'PATH' (which are must be\n    given as a single string separated with ':' between every two paths and without any spaces)\n- **_-d , --delete_**\n  - deletes from 'PATH' any number of paths (which are must be given as a single string separated\n    with ':' between every two paths and without any spaces)\n- **_-q , --query_**\n  - checks whether the given path is in the current 'PATH'\n- **_--remove-all-paths_**\n  - removes all paths in the current 'PATH' (NOT RECOMMENDED)\n- **_-v, --version_**\n  - show program version number and exit\n\n---\n\n### Code design:\n\n_The entire program is designed using the Functional Programming Paradigm and all application logic included in one file: 'project.py'._\n\n### Code documentation:\n\n#### Contents:\n\n- [pathvar.project module](#pathvarproject-module)\n\n  - [`add_args()`](#pathvarprojectadd_argsparser_obj-argumentparser)\n\n  - [`get_path()`](#pathvarprojectget_path)\n\n  - [`is_there_path()`](#pathvarprojectis_there_pathcurrent_path-str-given_path-str)\n\n  - [`main()`](#pathvarprojectmain)\n\n  - [`parse_args_and_modify_path_str()`](#pathvarprojectparse_args_and_modify_path_strparser_obj-argumentparser-current_path-str)\n\n  - [`path_duplicates_eliminator()`](#pathvarprojectpath_duplicates_eliminators-str)\n\n  - [`path_remover()`](#pathvarprojectpath_removercurrent_path-str-given_paths-str)\n\n  - [`print_msg()`](#pathvarprojectprint_msgtitle-str-msg-str)\n\n  - [`run_command_verbosely()`](#pathvarprojectrun_command_verboselycmd-str)\n\n  - [`update_path()`](#pathvarprojectupdate_pathnew_path_value-str)\n\n### pathvar.project module\n\n#### pathvar.project.add_args(parser_obj: ArgumentParser)\n\n_Adding CL arguments to and ArgumentParser object_\n\n_Manipulate the inputted ArgumentParser object\nby adding the needed command line arguments to it\nwith all the specifications for each of the arguments\n(i.e. argument name, action, help, …)._\n\n- **Parameters**\n\n  **parser_obj** (_argparse.ArgumentParser_) – parser object for parsing the command line arguments\n\n- **Returns**\n\n  None\n\n- **Return type**\n\n  None\n\n#### pathvar.project.get_path()\n\n_A simple function to get the current PATH_\n\n_Get the current PATH environment variable\nusing the command meant for that\ndepending on the kind of the operating system that pathvar running on._\n\n- **Returns**\n\n  The value of the PATH variable\n\n- **Return type**\n\n  str\n\n#### pathvar.project.is_there_path(current_path: str, given_path: str)\n\n_Check whether the ‘given_path’ is in ‘current_path’_\n\n_Return True if the ‘given_path’ is in ‘current_path’\nOtherwise, return false._\n\n- **Parameters**\n\n  - **current_path** (_str_) – The value inside the PATH environment variable\n\n  - **given_paths** (_str_) – The paths that the user want it to be deleted\n\n- **Returns**\n\n  True/False, based on whether the ‘given_path’ is in ‘current_path’\n\n- **Return type**\n\n  bool\n\n#### pathvar.project.main()\n\n_pathvar main function_\n\n_The Logic of the entire ‘pathvar’ program._\n\n- **Returns**\n\n  Nothing, just execute the logic of the entire program.\n\n- **Return type**\n\n  None\n\n#### pathvar.project.parse_args_and_modify_path_str(parser_obj: ArgumentParser, current_path: str)\n\n_Parsing the command line arguments_\n\n_Using ‘argparse’ library this function will consume an ‘ArgumentParser’ object\nin order to parse the arguments and handle the chosen option/s._\n\n- **Parameters**\n\n  **parser_obj** (_argparse.ArgumentParser_) – parser object for parsing the command line arguments\n\n- **Returns**\n\n  None\n\n- **Return type**\n\n  None\n\n#### pathvar.project.path_duplicates_eliminator(s: str)\n\n_Remove any duplicates in a PATH variable_\n\n_This function removes any duplicated paths from a PATH variable.\nIt looks for duplicated paths._\n\n- **Parameters**\n\n  **s** (_str_) – The value of the PATH environment variable\n\n- **Returns**\n\n  The same input of the PATH value without any duplicates\n\n- **Return type**\n\n  str\n\n#### pathvar.project.path_remover(current_path: str, given_paths: str)\n\n_Delete the given path/s from the current PATH_\n\n_return copy of the ‘current_path’\nwithout and value included in the ‘given_paths’_\n\n- **Parameters**\n\n  - **current_path** (_str_) – The value inside the PATH environment variable\n\n  - **given_paths** (_str_) – The paths that the user want it to be deleted\n\n- **Returns**\n\n  A copy from the current path without any given path\n\n- **Return type**\n\n  str\n\n#### pathvar.project.print_msg(title: str, msg: str)\n\n_Print message to the user_\n\n_This function will print a message to the user\nin form of message title and message body_\n\n- **Parameters**\n\n  - **title** (_str_) – The title of the message\n\n  - **msg** (_str_) – The body of the message\n\n- **Returns**\n\n  Nothing, just the print side effect\n\n- **Return type**\n\n  None\n\n#### pathvar.project.run_command_verbosely(cmd: str)\n\n_Run a given command in subprocess_\n\n_Run the given command in subprocess\nand print and ‘stdout’ or ‘stderr’_\n\n- **Parameters**\n\n  **cmd** (_str_) – Command to run\n\n#### pathvar.project.update_path(new_path_value: str)\n\n_Run a command to update the PATH variable_\n\n_Run the needed commands for updating the PATH environment variable\nbased on the current operating system and print any ‘stdout’ or ‘stderr’_\n\n- **Parameters**\n\n  **new_path_value** (_str_) – The new value in order to set the PATH variable to it\n\n---\n\n### License:\n\n\u003ch6 align=\"center\"\u003eCopyright (c) 2023 Hussein Mahmoud Kandil - MIT\u003ch6\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhussein-m-kandil%2Fpathvar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhussein-m-kandil%2Fpathvar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhussein-m-kandil%2Fpathvar/lists"}