{"id":25436674,"url":"https://github.com/nikolai2038/my-shell-environment","last_synced_at":"2026-04-13T12:31:17.142Z","repository":{"id":277608585,"uuid":"932900486","full_name":"Nikolai2038/my-shell-environment","owner":"Nikolai2038","description":"My personal shell environment customizations, which is both useful and simple to install","archived":false,"fork":false,"pushed_at":"2025-05-05T21:03:58.000Z","size":623,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-05T21:50:17.516Z","etag":null,"topics":["bash","bashrc","command-prompt","dash","environment","ksh","my-shell-environment","parsing","ps1","ps2","scripts","sh","shell","shell-customization","shell-environment","shell-scripts"],"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/Nikolai2038.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null}},"created_at":"2025-02-14T18:20:24.000Z","updated_at":"2025-05-05T20:59:50.000Z","dependencies_parsed_at":"2025-02-14T22:28:24.286Z","dependency_job_id":"a8cc2b81-dba0-4047-8bf1-74e5dfa3fc3a","html_url":"https://github.com/Nikolai2038/my-shell-environment","commit_stats":null,"previous_names":["nikolai2038/my-shell-environment"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nikolai2038%2Fmy-shell-environment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nikolai2038%2Fmy-shell-environment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nikolai2038%2Fmy-shell-environment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nikolai2038%2Fmy-shell-environment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Nikolai2038","download_url":"https://codeload.github.com/Nikolai2038/my-shell-environment/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254264766,"owners_count":22041794,"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","command-prompt","dash","environment","ksh","my-shell-environment","parsing","ps1","ps2","scripts","sh","shell","shell-customization","shell-environment","shell-scripts"],"created_at":"2025-02-17T08:21:36.065Z","updated_at":"2026-04-13T12:31:17.104Z","avatar_url":"https://github.com/Nikolai2038.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# my-shell-environment\n\n## 1. Description\n\nMy personal shell environment customizations, which is both useful and simple to install.\n\n## 2. Preview\n\n![Preview](./.readme_images/preview.png)\n\nStructure of the command prompt:\n\n```plaintext\n┌─[USER_NAME@PC_NAME:FULL_PATH_TO_THE_CURRENT_DIRECTORY]\n├─[OS_NAME]─[SHELL_DEPTH]─[SHELL_NAME]─$ COMMAND\nCOMMAND_OUTPUT\n└─[COMMAND_RETURN_CODE]─[EXECUTION_TIME_IN_SECONDS]─[FINISHED_DATE]─[FINISHED_DAY_OF_THE_WEEK]─[FINISHED_TIME]\n```\n\n## 3. Supported shells\n\n- `sh` (tested with start from `bash`);\n- `bash`;\n- `bash` (MINGW on Windows);\n- `dash` (tested with start from `bash`);\n- `ksh` (tested with start from `bash`).\n\n## 4. Installation\n\n1. Install required software:\n\n    - For Windows, install [Git](https://git-scm.com/downloads/win);\n    - For Linux, install:\n      - `git`;\n      - `sudo` command and grant your user permissions.\n\n    Other commands and packages will be installed by script itself:\n\n    - Required commands:\n\n        - `which`, `sudo`, `sed`, `grep`, `git`, `tput`, `sha256sum`, `date`.\n\n    - Optional commands:\n\n        - `pstree`: Will allow to output current shell depth.\n\n            NOTE: If you install `psmisc` in already applied \"my-shell-environment\", for shell depth to appear you need to do either of one:\n\n            - Open a **new terminal** (even **not a new shell**, because shell depth is recalculating based on the process tree);\n            - Or just execute (but this method will see current shell as level `0`, regardless of the parent shells number):\n\n                ```sh\n                _N2038_INIT_SHELL_DEPTH=\"\" \u0026\u0026 n2038_my_bash_environment activate\n                ```\n\n    If you don't want script to install anything - set environment variable `N2038_AUTO_INSTALL_PACKAGES` to `0` in your `.bashrc` or just in terminal - before installing `my-shell-environment`. Script will still hint you how to install all the commands.\n\n2. Open Bash terminal;\n3. Install:\n\n    - Stable version (`main` branch):\n\n        ```sh\n        rm -rf ~/.my-shell-environment; git clone --branch main https://github.com/Nikolai2038/my-shell-environment.git ~/.my-shell-environment \u0026\u0026 . ~/.my-shell-environment/n2038_my_shell_environment.sh \u0026\u0026 n2038_my_shell_environment install; rm -rf ~/.my-shell-environment\n        ```\n\n    - Development version (`dev` branch):\n\n        ```sh\n        rm -rf ~/.my-shell-environment; git clone --branch dev https://github.com/Nikolai2038/my-shell-environment.git ~/.my-shell-environment \u0026\u0026 . ~/.my-shell-environment/n2038_my_shell_environment.sh \u0026\u0026 n2038_my_shell_environment --dev install; rm -rf ~/.my-shell-environment\n        ```\n\n## 5. Uninstallation\n\n```sh\nsed -Ei '/(my-shell-environment|my_shell_environment)/d' \"${HOME}/.bashrc\" \u0026\u0026 \\\nsudo rm -rf \"${_N2038_SHELL_ENVIRONMENT_PATH}\"\n```\n\nThen reopen the terminal.\n\n## 6. Update\n\n```bash\nn2038_my_shell_environment update\n```\n\n## 7. Settings\n\nYou can set some environment variables to change \"my-shell-environment\" behaviour:\n\n- `N2038_PROGRAMS_PATH`: Path to directory, in which some programs (for example, JetBrains products) will be installed;\n- `N2038_DOWNLOADS_PATH`: Path to directory, in which files will be downloaded when needed by \"my-shell-environment\".\n\n## 8. Features\n\n### 8.1. Command prompt\n\nAs shown in preview above, these scripts when sourced will show information about:\n\n- Current user;\n- Hostname;\n- Full path to the current directory;\n- Current real shell (follows symlinks);\n- Exit code of the finished command. If it is not `0`, it will be red (can be seen on preview);\n- Execution time in seconds (only in `bash`);\n- Date and time when command was finished.\n\n### 8.2. Aliases\n\nAliases are stored as functions in files inside `./scripts/aliases` directory - you can see their implementation there.\n\nSome aliases have logic with provided arguments, but all of them are accepting any extra arguments after.\n\nThe equals (for example, `l` = `ls`) descriptions below are just informative - actual aliases have more complex logic than that.\n\n#### 8.2.1. `ls`\n\n- `l` = `ls`: Prints list of the files (exclude hidden);\n- `la` = `ls -a`: Prints list of the files (include hidden);\n- `ll` = `ls -l`: Prints list of the files (exclude hidden) with their details;\n- `lla` = `ls -la`: Prints list of the files (include hidden) with their details;\n- `lm`: Prints list of the files (exclude hidden) in Markdown format;\n- `lam` or `lma`: Prints list of the files (include hidden) in Markdown format.\n\n#### 8.2.2. `git`\n\n- `gs` = `git status`: Show Git repository status;\n- `ga [arg, default: .]` = `git add`: Add files to Git index. If no files specified, adds all files (`.`);\n- `gc \u003cmessage\u003e` = `git commit -m`: Commit changes with message;\n- `gpull` = `git pull`: Pull changes from remote repository;\n- `gpush` = `git push`: Push commits to remote repository;\n- `gp` = `git pull \u0026\u0026 git push`: Pull and then push changes to the remote repository;\n- `gl` = `git log`: Show beautified Git log. Shows a colorized log with commit hash, date, GPG signature, author, branches/tags, and commit message:\n\n    ![gl](./.readme_images/git_log.png)\n\n#### 8.2.3. `docker`\n\nMain:\n\n- `dps` = `docker ps`: Prints list of the running containers;\n- `dpi` = `docker images`: Prints colorful list of the images with line format:\n\n    ```plaintext\n    \u003cimage\u003e:\u003ctag\u003e (\u003csize\u003e)\n    ```\n\nExtra:\n\n- `dpsq` = `docker ps -q`: Prints list of hashes of the running containers;\n- `dpsa` = `docker ps -a`: Prints list of all containers (running and stopped);\n- `dpsaq` = `docker ps -aq`: Prints list of hashes of all containers (running and stopped).\n\n#### 8.2.4. `docker-compose`\n\nMain:\n\n- `dc` = `docker-compose`;\n- `dcu` = `docker-compose up --detach --wait`;\n- `dcb` = `docker-compose build`;\n- `dcd` = `docker-compose down`;\n- `dcr` = `docker-compose restart`;\n- `dcl` = `docker-compose logs`;\n- `dcps` = `docker-compose ps`;\n\nExtra:\n\n- `dcud` = `docker-compose up --detach --wait \u0026\u0026 docker-compose down`;\n- `dcbu` = `docker-compose build \u0026\u0026 docker-compose up --detach --wait`;\n- `dcbud` = `docker-compose build \u0026\u0026 docker-compose up --detach --wait \u0026\u0026 docker-compose down`;\n- `dcbdu` = `docker-compose build \u0026\u0026 docker-compose down \u0026\u0026 docker-compose up --detach --wait`;\n- `dcdb` = `docker-compose down \u0026\u0026 docker-compose build`;\n- `dcdu` = `docker-compose down \u0026\u0026 docker-compose up --detach --wait`;\n- `dcdbu` = `docker-compose down \u0026\u0026 docker-compose build \u0026\u0026 docker-compose up --detach --wait`;\n- `dcpsa` = `docker-compose ps -a`;\n- `dcpsq` = `docker-compose ps -q`;\n- `dcpsaq` = `docker-compose ps -aq`.\n\n### 8.3. Scripts\n\n#### 8.3.1. JetBrains\n\n#### 8.3.1.1. `n2038_jetbrains_install.sh` - Install specified JetBrains product (latest stable) for current OS\n\nUsage:\n\n```sh\nn2038_jetbrains_install.sh \u003cproduct_name\u003e\n```\n\nWhere:\n\n- `product_name` can be one of the: `idea`, `phpstorm`, `clion`, `pycharm`, `webstorm`, `rider`, `rubymine`, `rustrover`, `writerside`, `datagrip`, `dataspell`, `fleet`, `goland`.\n\n#### 8.3.1.2. `n2038_jetbrains_download.sh` - Download specified JetBrains product (latest stable installer) in the downloads directory\n\nUsage:\n\n```sh\nn2038_jetbrains_download.sh \u003cproduct_name\u003e \u003cdownload_type\u003e\n```\n\nWhere:\n\n- `product_name` can be one of the: `idea`, `phpstorm`, `clion`, `pycharm`, `webstorm`, `rider`, `rubymine`, `rustrover`, `writerside`, `datagrip`, `dataspell`, `fleet`, `goland`;\n- `download_type` can be on of the: `linuxARM64`, `linux`, `windows`, `thirdPartyLibrariesJson`, `windowsZip`, `windowsARM64`, `mac`, `macM1`.\n\n#### 8.3.1.3. `n2038_jetbrains_clear_all_data.sh` - Clear all data of the JetBrains products (reset all settings, logins, etc.)\n\nUsage:\n\n```sh\nn2038_jetbrains_clear_all_data.sh\n```\n\n#### 8.3.2. `n2038_firefox_search_engines_export.sh` and `n2038_firefox_search_engines_import.sh` - Export and import Firefox's search engines\n\nSince Firefox does not sync search engines (and even more - it does not allow editing them), I wrote these scripts to export and import them. Usage:\n\n```sh\nn2038_firefox_search_engines_export.sh [--dev] \u003cfile_path\u003e\n```\n\nWhere:\n\n- `--dev`: If to use Firefox for Developers instead of default Firefox;\n- `--mozlz4`: If to export in \"mozlz4\" format, not JSON. In this case command \"mozlz4\" not needed to be installed (useful on Windows);\n- `file_path`: Path to the file where search engines data will be saved. Format is JSON.\n\nAnd:\n\n```sh\nn2038_firefox_search_engines_import.sh [--dev] \u003cfile_path\u003e\n```\n\nWhere:\n\n- `--dev`: If to use Firefox for Developers instead of default Firefox;\n- `--mozlz4`: If provided file is in \"mozlz4\" format, not JSON. In this case command \"mozlz4\" not needed to be installed (useful on Windows);\n- `file_path`: Path to the file from where search engines data will be loaded.\n\nExample 1:\n\n```sh\n# Save search engines from Firefox for Developers into file\nn2038_firefox_search_engines_export.sh --dev search.json\n\n# Load search engines for default Firefox from file\nn2038_firefox_search_engines_import.sh search.json\n\n# Remove temp file\nrm search.json\n```\n\nExample 2 (we assume, that `my-shell-environment` is already installed on both machines):\n\n1. On the Linux Machine:\n\n    ```sh\n    # Save search engines from Firefox for Developers into file without extracting \"mozlz4\"\n    n2038_firefox_search_engines_export.sh --dev --mozlz4 search.json.mozlz4\n    ```\n\n2. Move file `search.json.mozlz4` to the Windows machine;\n3. On the Windows machine:\n\n    ```sh\n    # Load search engines for default Firefox from file without extracting \"mozlz4\"\n    n2038_firefox_search_engines_import.sh --mozlz4 search.json.mozlz4\n\n    # Remove temp file\n    rm search.json.mozlz4\n    ```\n\n#### 8.3.3. `n2038_check_port.sh` - Check if port is open on the specified host\n\nUsage:\n\n```sh\nn2038_check_port.sh \u003chost\u003e:\u003cport\u003e [\u003cproxy_host\u003e:\u003cproxy_port\u003e]\n```\n\nWhere:\n\n- `host`: Host to connect;\n- `port`: Port to connect;\n- `proxy_host`: Host of the proxy to use before checking connection;\n- `proxy_port`: Port of the proxy to use before checking connection.\n\nFor usage with proxy command `proxytunnel` must be installed.\n\n## 9. More information\n\n### 9.1. About `n2038` prefix\n\n`n2038` prefix was chosen from my nickname to use something unique - to not be confused with system scripts. All functions except aliases have it.\n\n### 9.2. Environment variables (to customize environment)\n\nThese constants can be overridden via environment variables:\n\n- `N2038_IS_DEBUG`: If debug mode is enabled (more logs will be shown);\n- (must be overridden before installation) `_N2038_SHELL_ENVIRONMENT_NAME`: Name for the scripts folder and name to be shown in logs;\n- (must be overridden before installation)`_N2038_SHELL_ENVIRONMENT_REPOSITORY_URL`: Repository URL to install scripts from;\n\n### 9.3. Code style\n\n#### 9.3.1. Naming\n\n- I use `n2038_` prefix for all variables and functions to not be confused with other ones in the system;\n- I use `_` prefix for variables, which are not intended to be changed by the user;\n- I use `_` prefix for functions, which are not intended to be executed by the user (but by the developer - can and must be interactive and informative about it);\n- I use `__` prefix for local variables, constants and functions, which will not be available outside function;\n    - Special function `_n2038_unset` is used to unset all local variables and constants - so use them in one function only. If you want to temporarily export some variable to be used in another function - consider it as constant and prefix it with `_`. Unset it by hand when not needed anymore (for example, `_N2038_RETURN_CODE_PS1` and `_N2038_PWD_BEFORE_IMPORTS_*` are like that);\n- I try to use `sh` syntax on main elements of the shell environment. In the future, I will add several customizations for `bash` and probably some other shells when I will get to them.\n\n#### 9.3.2. Syntax\n\n- Each shell script contains function with same name. Exceptions: constants and aliases (see below for more info about them). All code done in function and `return`'s are used. We pass all the arguments to this function and check them all in it. After function call, return code is checked. If it is not `0`, we `exit` or `return` from the script based on if it was executed or sourced (see `_n2038_return` for more context).\n\n#### 9.3.3. Returns and exits\n\n- Each command, which can return non-zero return code, must end with `|| return \"$?\"`, `|| exit \"$?\"` or `|| true`;\n- `exit` is forbidden to be used inside functions - only `return`. This is because we can source shell script and execute function directly in the shell - so calling `exit` from it will result in shell exit (terminal close or disconnection from the remote);\n- Instead of `some_function || return \"$?\"` use `some_function || { _n2038_unset \"$?\" \u0026\u0026 return \"$?\" || return \"$?\"; }`:\n- Before `return 0` use `unset` to unset all local variables;\n- Instead of (for example) `return \"${_N2038_RETURN_CODE_WHEN_ERROR_WITH_MESSAGE}\"` use `_n2038_unset \"${_N2038_RETURN_CODE_WHEN_ERROR_WITH_MESSAGE}\" \u0026\u0026 return \"$?\" || return \"$?\"`.\n\n#### 9.3.4. Constants\n\n- Constants are stored in `_constants.sh` files (can be several) and usually does not have main function at all;\n- I use UPPERCASE names for constants. For example, `N2038_IS_DEBUG`.\n\n#### 9.3.5. Aliases\n\n- Aliases are stored as group of functions in `./scripts/aliases` folder;\n- I prefer functions over aliases because they:\n\n    - Provide more ways to play with arguments;\n    - Easily maintained for large aliases (syntax highlight, references to other functions, space for comments).\n\n#### 9.3.6. Other\n\n- When printing colored messages with highlights, make sure to surround highlights with quotation marks too. This way they will be more readable in logs and notes;\n- Use `curl --fail -L -o` instead of `wget -O`, because `wget` is not available in MINGW by default, but `curl` is.\n\n## 9. Contribution\n\nFeel free to contribute via [pull requests](https://github.com/Nikolai2038/my-shell-environment/pulls) or [issues](https://github.com/Nikolai2038/my-shell-environment/issues)!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikolai2038%2Fmy-shell-environment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnikolai2038%2Fmy-shell-environment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikolai2038%2Fmy-shell-environment/lists"}