{"id":18438662,"url":"https://github.com/seapagan/mchdir","last_synced_at":"2025-04-07T21:31:57.407Z","repository":{"id":257276712,"uuid":"857791481","full_name":"seapagan/mchdir","owner":"seapagan","description":"Make and change into a folder in one operation","archived":false,"fork":false,"pushed_at":"2025-03-31T03:23:36.000Z","size":1153,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-05T13:53:23.357Z","etag":null,"topics":["make-directory","make-folder","mcd"],"latest_commit_sha":null,"homepage":"https://seapagan.github.io/mchdir/","language":"Rust","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/seapagan.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-15T16:12:34.000Z","updated_at":"2024-12-30T15:57:04.000Z","dependencies_parsed_at":"2024-11-06T06:24:08.165Z","dependency_job_id":"e31e533e-0756-4154-ae45-024e5768ef45","html_url":"https://github.com/seapagan/mchdir","commit_stats":null,"previous_names":["seapagan/mchdir"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seapagan%2Fmchdir","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seapagan%2Fmchdir/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seapagan%2Fmchdir/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seapagan%2Fmchdir/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/seapagan","download_url":"https://codeload.github.com/seapagan/mchdir/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247345823,"owners_count":20924101,"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":["make-directory","make-folder","mcd"],"created_at":"2024-11-06T06:21:03.827Z","updated_at":"2025-04-07T21:31:57.119Z","avatar_url":"https://github.com/seapagan.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mchdir \u003c!-- omit in toc --\u003e\n\nA utility for creating a new folder then changing into it in one command,\nchanging to the last remembered directory or creating and changing into a\ntemporary folder.\n\nWritten in Rust and using shell integration.\n\n- [Description](#description)\n  - [Why?](#why)\n  - [Why the need for shell integration too?](#why-the-need-for-shell-integration-too)\n- [Features](#features)\n- [Installation](#installation)\n  - [Prerequisites](#prerequisites)\n  - [Install from Crates.io](#install-from-cratesio)\n  - [Build from Source](#build-from-source)\n  - [Install from GitHub](#install-from-github)\n- [Shell Integration](#shell-integration)\n  - [Automatic Installation](#automatic-installation)\n  - [Manually Add the Integration Code to Your Shell Configuration](#manually-add-the-integration-code-to-your-shell-configuration)\n    - [Bash, Zsh (and other Bash-Like Shells)](#bash-zsh-and-other-bash-like-shells)\n    - [Fish Shell](#fish-shell)\n  - [Fully Manual Installation](#fully-manual-installation)\n- [Usage](#usage)\n  - [`mcd` Command](#mcd-command)\n  - [`mct` Command](#mct-command)\n  - [`mcl` Command](#mcl-command)\n  - [mchdir Command](#mchdir-command)\n- [License](#license)\n- [Contributing](#contributing)\n\n## Description\n\n`mchdir` is a command-line tool written in Rust that allows you to create a new\ndirectory and immediately change into it. It includes shell integration that\ndefines an a couple of helpful commands in your shell, simplifying directory\ncreation and navigation.\n\nDocumentation is available at\n[https://seapagan.github.io/mchdir/](https://seapagan.github.io/mchdir/).\n\n### Why?\n\nI was getting tired of creating a new directory and then changing into it with\ntwo separate commands. I wanted a single command that could do both. I wrote a\nutility to do this decades ago on Windows, and I wanted the same functionality\non Linux/macOS.\n\nIt's true that you can do the same thing with a simple shell function or alias!\nHowever, this project is a demonstration of how to create a command-line tool in\nRust that provides (and installs!) shell integration. It will also probably get\nmore features in the future.\n\n### Why the need for shell integration too?\n\nIt is impossible to change the current working directory of the parent process\nfrom a child process (i.e., a command). This is because each process has its own\nworking directory, and changes to the working directory are not propagated to\nthe parent process. Hence, the mcd command cannot change the working directory\nof the shell that runs it without shell integration.\n\n## Features\n\n- Create a new directory and change into it with a single command (`mcd`).\n- Create a new directory in the system temporary directory and change into it\n  with the `mct` command.\n- Change back to the last directory with the `mcl` command.\n- Shell integration for bash, zsh, and fish shells as first-class citizens,\n  though it should work in most POSIX-compliant shells too.\n- Supports automatic installation of shell integration scripts.\n\n## Installation\n\nIn the future, there will be pre-built binaries available for download. For now,\nyou can install `mchdir` from crates.io, build it from source, or install it\ndirectly from GitHub.\n\n### Prerequisites\n\n- Rust programming language (for building from source)\n- cargo package manager\n- Linux or macOS (**Windows is not supported**)\n\n### Install from Crates.io\n\nYou can install the `mchdir` command from the crates.io registry using the\nfollowing command:\n\n```terminal\ncargo install mchdir\n```\n\n### Build from Source\n\nClone the repository:\n\n```terminal\ngit clone https://github.com/seapagan/mchdir.git\ncd mchdir\n```\n\nBuild the project:\n\n```terminal\ncargo build --release\n```\n\nThis will produce an executable in the target/release directory.\n\nInstall the Executable:\n\nCopy the executable to a directory in your $PATH, for example:\n\n```terminal\nsudo cp target/release/mchdir /usr/local/bin/\n```\n\n### Install from GitHub\n\nYou can also install the `mchdir` command directly from GitHub using the following\ncommand:\n\n```terminal\ncargo install --git https://github.com/seapagan/mchdir.git\n```\n\n## Shell Integration\n\nTo enable the `mcd`, `mcl` and `mct` commands in your shell, you need to\nintegrate `mchdir` with your shell configuration.\n\n### Automatic Installation\n\nYou can automatically install the shell integration by running:\n\n```terminal\nmchdir install\n```\n\nThis command will detect your shell and append the necessary integration code to\nthe bottom of your shell configuration file (e.g., `~/.bashrc`, `~/.zshrc`, or\n`~/.config/fish/config.fish`).\n\n**Note**: Currently, automatic installation supports bash, zsh, and fish shells.\nFor other shells, please follow the manual installation instructions. The shell\nintegration code is POSIX-compliant and should work in most shells, or only need\nminor modifications.\n\nAfter running the installation command, restart your shell or source your\nconfiguration file to apply the changes:\n\n```terminal\n# For bash and zsh\nsource ~/.bashrc  # or source ~/.zshrc\n\n# For fish\nsource ~/.config/fish/config.fish\n```\n\n### Manually Add the Integration Code to Your Shell Configuration\n\nInstead of using the automatic installation, you can manually add the shell\nintegration code to your shell configuration file. Below is an example of how to\ndo this for different shells.\n\n#### Bash, Zsh (and other Bash-Like Shells)\n\nFor `bash`, add the following code to your `~/.bashrc` file:\n\n```terminal\neval \"$(mchdir init)\"\n```\n\nFor `zsh`, add the following code to your `~/.zshrc` file:\n\n```terminal\neval \"$(mchdir init)\"\n```\n\n#### Fish Shell\n\nFor the `fish` shell, add the following code to your\n`~/.config/fish/config.fish` file:\n\n```terminal\neval (mchdir init)\n```\n\nAfter adding this command to your shell configuration command, restart your\nshell or source your configuration file to apply the changes.\n\n### Fully Manual Installation\n\nIf you prefer manual installation or your shell is not supported, you can\ngenerate the shell integration code and add it to your shell configuration\nmanually.\n\nGenerate the integration code:\n\n```terminal\nmchdir init\n```\n\nThis command will output the shell function definition for mcd and mct. Copy the output\nand paste it into your shell's configuration file.\n\nAfter pasting this code into your shell configuration command, restart your\nshell or source your configuration file to apply the changes.\n\n## Usage\n\nNote that after installation, you no longer need to run the `mchdir` command\nagain, unless you need to reinstall the shell integration. It DOES need to\nremain in your PATH for the shell integration to work however.\n\n### `mcd` Command\n\n- Create a new directory and change into it:\n\n  ```terminal\n  mcd my_new_directory\n  ```\n\n- Change to the home directory (when no argument is provided):\n\n  ```terminal\n  mcd\n  ```\n\n- Display help for the mcd command:\n\n  ```terminal\n  mcd --help\n  ```\n\nOutput:\n\n```terminal\nUsage: mcd \u003cdirectory\u003e\nCreates a new directory and changes into it.\nIf no directory is specified, changes to the home directory.\n```\n\n### `mct` Command\n\n- Create a new directory in the system temporary directory and change into it:\n\n  ```terminal\n  mct my_temp_directory\n  ```\n\n- Create a truly random directory in the system temporary directory and change\n  into it (when no argument is provided):\n\n  ```terminal\n  mct\n  ```\n\n- Display help for the `mct` command:\n\n  ```terminal\n  mct --help\n  ```\n\nOutput:\n\n```terminal\nUsage: mct \u003cdirectory\u003e\n    Creates a new directory in the system temporary directory and changes into it.\n    If no directory is specified, creates a random directory in the temp folder.\n```\n\n### `mcl` Command\n\n- Changes to the previous directory the shell was in:\n\n  ```terminal\n  mcl\n  ```\n\n- Display help for the `mcl` command:\n\n  ```terminal\n  mcl --help\n  ```\n\n### mchdir Command\n\nThe `mchdir` command supports the following subcommands:\n\n- Display the shell integration code:\n\n  ```terminal\n  mchdir init\n  ```\n\n- Install the shell integration automatically:\n\n  ```terminal\n  mchdir install\n  ```\n\nAgain, you only need to run the `mchdir` command when initially installing the\nshell integration or when you want to reinstall it.\n\n## License\n\n```pre\nThe MIT License (MIT)\nCopyright (c) 2024 Grant Ramsay\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\nDAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\nOTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE\nOR OTHER DEALINGS IN THE SOFTWARE.\n```\n\n## Contributing\n\nContributions are welcome! Please open an issue or submit a pull request on\nGitHub.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseapagan%2Fmchdir","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseapagan%2Fmchdir","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseapagan%2Fmchdir/lists"}