{"id":17383201,"url":"https://github.com/happycod3r/term-lock","last_synced_at":"2026-04-17T07:33:10.422Z","repository":{"id":177406526,"uuid":"660343865","full_name":"happycod3r/Term-Lock","owner":"happycod3r","description":"Term-Lock is a simple pin system that allows you to block access and add a layer of security to your terminal.","archived":false,"fork":false,"pushed_at":"2023-07-10T19:28:11.000Z","size":22,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-27T20:49:42.577Z","etag":null,"topics":["bash","bashrc","extension","oh-my-zsh-custom","ohmyzsh","omz","omz-plugin","security","shell-extension","shellscript","term-lock","terminal-security","v1","zsh","zshrc"],"latest_commit_sha":null,"homepage":"","language":"Shell","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/happycod3r.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-29T19:50:48.000Z","updated_at":"2023-07-07T20:26:37.000Z","dependencies_parsed_at":"2023-07-22T22:01:39.420Z","dependency_job_id":null,"html_url":"https://github.com/happycod3r/Term-Lock","commit_stats":null,"previous_names":["happycod3r/term-lock"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/happycod3r%2FTerm-Lock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/happycod3r%2FTerm-Lock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/happycod3r%2FTerm-Lock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/happycod3r%2FTerm-Lock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/happycod3r","download_url":"https://codeload.github.com/happycod3r/Term-Lock/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245924495,"owners_count":20694728,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","bashrc","extension","oh-my-zsh-custom","ohmyzsh","omz","omz-plugin","security","shell-extension","shellscript","term-lock","terminal-security","v1","zsh","zshrc"],"created_at":"2024-10-16T07:40:54.659Z","updated_at":"2026-04-17T07:33:10.373Z","avatar_url":"https://github.com/happycod3r.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Term-Lock v1.0.0\r\n\r\n```bash\r\n _______  ______  _____   __  __          _        ____    _____  _  __\r\n|__   __||  ____||  __ \\ |  \\/  |        | |      / __ \\  / ____|| |/ /\r\n   | |   | |__   | |__) || \\  / | ______ | |     | |  | || |     | ' / \r\n   | |   |  __|  |  _  / | |\\/| ||______|| |     | |  | || |     |  \u003c  \r\n   | |   | |____ | | \\ \\ | |  | |        | |____ | |__| || |____ | . \\ \r\n   |_|   |______||_|  \\_\\|_|  |_|        |______| \\____/  \\_____||_|\\_\\\r\n                                                   \r\n```\r\n\u003e If you need to stop unauthorized access to your terminal Term-Lock is a simple solution\r\n\r\n- [About](#about)\r\n- [Install](#install)\r\n  - [Manual Install](#manual_install)\r\n  - [Command Line Install](#command_line_install)\r\n    - [Using Git Clone](#git_clone)\r\n    - [Using Curl](#curl)\r\n- [Usage](#usage)\r\n  - [Stand Alone](#standalone)\r\n  - [Oh-My-Zsh](#ohmyzsh)\r\n  - [Integration](#integration)\r\n- [Notes](#notes)\r\n- [Contributing](#contributing)\r\n- [Security](#security)\r\n- [Contacts](#contacts)\r\n\r\n---\r\n\r\n## [About](#about)\r\n\r\nTerm-Lock is a simple 1 way authentification system that allows you to block access and add a layer of security to your terminal by prompting for a pin which is then encrypted and stored on the system in a hidden file and folder.\r\n\r\nYou can use this as a stand-alone script or integrate it easily into frameworks such as oh-my-zsh. Since Term-Lock is wrapped into one function, it's all that needs to be called to work and you can place the call to term_lock wherever you want. If you have some functionality you want to block or a route in the control flow of your shell code that you want to protect and secure access to, just place a call to `term_lock` before it, and this will put a barrier between what you want to protect and unauthorized usage. You will now need a pin to continue the control flow or move on in any instance. \r\n\r\nI do plan on building on this in the near future to make it more secure with better encryption methods and functionality in general. I also plan on adding the option to change the pin size for tighter security. Right now though, Term-Lock v1.0.0 works well, is lightweight, and easy to use.  \r\n\r\nFor example check out this hypothetical function call stack: \r\n```bash\r\ninit               # 1) called 1st\r\nset_up_data        # 2) called 2nd\r\ndo_stuff           # 3) called 3rd\r\ndo_more_stuff      # 4) called 4th\r\nterm_lock          # 5) prompts for the pin\r\npass_ctrl_to_user  # 6) If wrong/no pin entered in step 5 this never gets called.\r\n```\r\nIn the above example you will now no longer be able to reach `pass_ctrl_to_user` without entering the correct pin holding back unauthorized usage.\r\n\r\nPlacing the call at the top of your ***.zshrc*** or your ***.bashrc*** will have the same effect as above effectively locking down your terminal by blocking further execution unless you have the pin. Follow the [usage](#usage) section below to set it up.\r\n\r\n---\r\n\r\n## [Install](#install)\r\n\r\nTo download and install Term-Lock follow choose an install method and follow the corresponding steps. Once\r\nfininshed jump to the [Usage](#usage) section.\r\n\r\n### [Manual Install](#manual_install) \r\n\r\n1. Download and place the ***zsh-toggles*** folder in a location of your choosing.\r\n2. Next source the script as shown in the [Usage](#usage) section. \r\n\r\n### [Command Line Install](#command_line_install)\r\n\r\n#### [Using Git Clone:](#git_clone)\r\n\r\n1) Open your terminal and navigate to the directory where you want to clone the repository: \r\n\r\n```bash\r\ncd where/I/want/to/install\r\n```\r\n\r\n2) Next run the following command to clone the repository to the chosen location:\r\n```bash\r\ngit clone https://github.com/happycod3r/Term-Lock.git\r\n```\r\n\r\n#### [Using Curl:](#curl)\r\n\r\n1) Pick a directory to download it to:\r\n```bash\r\ncd where/I/want/\r\n```\r\n\r\n2) Paste the following line into your terminal and press the `Enter (^M)` key:\r\n```bash\r\ncurl https://github.com/happycod3r/Term-Lock.git\r\n```\r\n\r\n## [Usage](#usage)\r\n\r\n### [oh-my-zsh](#ohmyzsh)\r\n\r\nTo use **term-lock** with **oh-my-zsh** follow these steps:\r\n\r\n1) Simply move the term-lock folder to the `~/.oh-my-zsh/custom/plugins` directory and then add ***term-lock*** to the ***plugins*** array in your ***~/.zshrc*** file.\r\n\r\n```bash\r\nplugins=(... term-lock ...)\r\n```\r\n\r\n2) If you don't want any plugins to load before term-lock, then place ***term-lock*** first in the ***plugins*** array. If you want term-lock to run even before **oh-my-zsh** all together then see the next section on [Stand Alone](#standalone) usage.\r\n\r\n```bash\r\nplugins=(term-lock ... ...)\r\n```\r\n\r\n**Bash**\r\n\r\n1) To use term-lock to create a pin and lock down access to your terminal add the following code to the very top of your ***.bashrc*** or ***.zshrc*** file.\r\n\r\n```bash\r\n# Put the term-lock folder where you would like then update the $TERM_LOCK variable\r\n# with the new path\r\nTERM_LOCK=\"~/term-lock\"\r\n[[ -f \"${TERM_LOCK}/term-lock.sh\" ]] \u0026\u0026 { source \"${TERM_LOCK}/term-lock.sh\"; term_lock; }\r\n\r\n# Everything else ...\r\n```\r\n\r\n**Zsh**\r\n\r\n```bash\r\n# Put the term-lock folder where you would like then update the $TERM_LOCK variable\r\n# with the new path\r\nTERM_LOCK=\"~/term-lock\"\r\n[[ -f \"${TERM_LOCK}/term-lock.zsh\" ]] \u0026\u0026 { builtin source \"${TERM_LOCK}/term-lock.zsh\"; term_lock; }\r\n\r\n# Everything else ...\r\n```\r\n\r\nOnce the `term-lock.sh` script is sourced at the top of your ***.bashrc*** or ***.zshrc*** you will now have to enter a 4 digit pin when you start the terminal.\r\nOn the first run you will be asked to setup the pin. It should be only 4 digits long with no letters or characters.\r\n\r\nIf you want to reset your pin change the line above where the `term_lock` function is called by passing it ***\"true\"*** as an argument like so:\r\n\r\n```bash\r\n   TERM_LOCK=\"~/term-lock\"\r\n[[ -f \"${TERM_LOCK}/term-lock.zsh\" ]] \u0026\u0026 { builtin source \"${TERM_LOCK}/term-lock.zsh\"; term_lock \"true\"; }\r\n```\r\n\r\nOnce you finish resetting your pin remove the value ***\"true\"*** that you added so that you don't reset your pin over again by accident.\r\n\r\nYou can also alternatively manually delete the `.pin.conf` file created by Term-Lock to hard reset your pin.\r\nSince Term-Lock uses this file as a flag, it will prompt you to create a new pin when it doesn't detect it.\r\n\r\n\r\n```bash \r\n#Change \r\nterm_lock \"true\"\r\n#to...\r\nterm_lock\r\n\r\n\r\n```\r\n\r\nYou can use term_lock in many ways. Here's some examples:\r\n\r\n```bash\r\nif [[ $login == \"true\" ]]; then\r\n   term_lock\r\n\r\n```\r\n\r\n### Integration\r\n \r\nYou can also integrate Term-Lock easily into anything really by copying the function and placing it where you would like or sourcing it as described in the beginning of this section.\r\n\r\nFor integration purposes there is the `$USE_PIN` variable, which by default is set to `true`.\r\nYou can set it to `false` to turn off Term-lock and bypass the pin. In this way it acts as a switch that you can easily write some code to turn on/off based on whatever conditions. \r\n\r\n```bash \r\nif [[ $some_condition == \"true\" ]]; then\r\n   # Won't ask for pin next time around.\r\n   USE_PIN=\"false\"\r\nelif [[ $some_condition == \"false\" ]]; then\r\n   # Block access, ask for pin on next run.\r\n   USE_PIN=\"true\"\r\nfi\r\n```\r\n\r\n---\r\n\r\n## [Notes](#notes) \r\n\r\nThis is by no means a full proof way to stop a person from accessing your termnal. Anyone who knows what they are doing will still be able to get access. On the other hand the majority of people who don't really know much about computers aside from the basics like your little brother or family member for example will be stopped by this.\r\nEither way it adds a layer of security so it's always beneficial.\r\n\r\nIn the future I will add an option to lengthen or shorten the pin for better security.\r\n\r\n---\r\n\r\n## [Contributing](#contributing)\r\n\r\nIf you have any feature requests, suggestions or general questions you can reach me via any of the methods listed below in the [Contacts](#contacts) section.\r\n\r\n---\r\n\r\n## [Security](#security)\r\n\r\n### Reporting a vulnerability or bug?\r\n\r\n**Do not submit an issue or pull request**: A general rule of thumb is to never publicly report bugs or vulnerabilities because you might inadvertently reveal it to unethical people who may use it for bad. Instead, you can email me directly at: [paulmccarthy676@gmail.com](mailto:paulmccarthy676@gmail.com). I will deal with the issue privately and submit a patch as soon as possible.\r\n\r\n---\r\n\r\n## [Contacts](#contacts)\r\n\r\n**Author:** Paul M.\r\n\r\n* Email: [paulmccarthy676@gmail.com](mailto:paulmccarthy676@gmail.com)\r\n* Github: [https://github.com/happycod3r](https://github.com/happycod3r)\r\n* Linkedin: [https://www.linkedin.com/in/paul-mccarthy-89165a269/]( https://www.linkedin.com/in/paul-mccarthy-89165a269/)\r\n* Facebook: [https://www.facebook.com/paulebeatz]( https://www.facebook.com/paulebeatz)\r\n\r\n---\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhappycod3r%2Fterm-lock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhappycod3r%2Fterm-lock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhappycod3r%2Fterm-lock/lists"}