{"id":13567435,"url":"https://github.com/spencertipping/cd","last_synced_at":"2025-04-09T23:41:06.683Z","repository":{"id":66624531,"uuid":"9280453","full_name":"spencertipping/cd","owner":"spencertipping","description":"A better \"cd\" for bash","archived":false,"fork":false,"pushed_at":"2021-09-29T13:40:15.000Z","size":72,"stargazers_count":98,"open_issues_count":0,"forks_count":9,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-24T01:35:15.797Z","etag":null,"topics":["bash-hacks","encfs","fuse","shell","sshfs"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spencertipping.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2013-04-07T17:42:33.000Z","updated_at":"2025-02-11T17:31:17.000Z","dependencies_parsed_at":"2023-02-22T16:15:52.235Z","dependency_job_id":null,"html_url":"https://github.com/spencertipping/cd","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spencertipping%2Fcd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spencertipping%2Fcd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spencertipping%2Fcd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spencertipping%2Fcd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spencertipping","download_url":"https://codeload.github.com/spencertipping/cd/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248131468,"owners_count":21052819,"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-hacks","encfs","fuse","shell","sshfs"],"created_at":"2024-08-01T13:02:31.444Z","updated_at":"2025-04-09T23:41:06.663Z","avatar_url":"https://github.com/spencertipping.png","language":"Shell","funding_links":[],"categories":["Shell"],"sub_categories":[],"readme":"# `cd`, but better\nA replacement for the default bash/zsh `cd` command. It can mount FUSE\nfilesystems on-demand, jump down multiple levels of directories, etc. `cd`\nalways prefers real directories to special commands; so if you had a directory\ncalled `foo:`, `cd foo:` would just cd into `foo:`, not try to mount `foo:`\nwith sshfs.\n\n```sh\n$ cd machine-name:[path]    # automounts machine-name:path with sshfs\n$ cd /dev/sdb1              # create a mountpoint, then sudo-mount it\n$ cd **x                    # cd's to the first descendant dir matching /x/\n$ cd ..5                    # cd's up five directories\n$ cd ..foo                  # cd's up to the nearest dir matching /foo/\n$ cd x.tar                  # mounts x.tar with archivemount\n$ cd y.zip                  # mounts y.zip with archivemount\n$ cd hdfs://namenode:9000   # mounts namenode with hadoop-fuse-dfs\n$ cd ^                      # history: go back one directory\n$ cd ^^                     # history: go back two directories\n$ cd ^10                    # history: go back ten directories\n$ cd -10                    # history: go back ten directories\n$ cd ^foo                   # history: go back to last dir matching /foo/\n$ cd nfs:machine:/woot      # mounts NFS directories\n$ cd enc:/path/to/encrypted # mounts an encfs directory\n$ cd loop:image.iso         # mounts a loopback image\n$ cd au:/usr:/var           # AUFS union mount\n$ cd s3://bucket            # s3fs (note that subpaths don't work yet)\n\n# deprecated commands:\n$ cd git:/path/to/repo      # mounts git commits as directories (requires YaGFS)\n```\n\n`cd git:` is now deprecated in favor of [ni's git\nsupport](https://github.com/spencertipping/ni/blob/develop/doc/git.md), which is\nfar more complete and portable.\n\nFuse and root-mounted directories are unmounted automatically when you `cd` out\nof them.\n\n`cd` also supports symlinks to virtual directories. For example:\n\n```sh\n$ ln -s machine-name:/foo/bar my-symlink\n$ cd my-symlink             # same as cd machine-name:/foo/bar\n```\n\nIf you want `cd` to virtualize the destination of a symlink, the symlink must\nnot point to a real directory.\n\n## Using with zsh\n`cd` works just fine with zsh, but you'll need to make sure of a few things.\nFirst, make sure `KSH_ARRAYS` is **unset** when you load the script; otherwise\n`cd` will be in bash-compatible mode and will break under zsh. Second, `cd`\nwill set `BASH_REMATCH` and assumes that you'll leave it set (sorry). So if you\nunset it, `cd` will start having problems.\n\nAlso, `cd` will nuke any existing `zsh_exit` you have defined. If you care\nabout this, ping me and I'll make it non-clobbering.\n\n## Interactive options\n```sh\n$ cd --history              # prints $PWD history, most recent first\n$ cd --mounts               # lists probably-active FUSE mount points\n$ cd --patterns             # all patterns that 'cd' is looking for\n$ cd --clean                # attempts to unmount and remove all mounts\n$ cd --which enc:x          # indicates which delegate is used for enc:x\n```\n\nThe `--clean` option is good for cases where FUSE mountpoints are left in an\ninconsistent state; for instance, when you suspend a machine with an open SSHFS\nconnection. It will unmount and remove all mountpoints that aren't in use.\n\n## Setup\nTo enable it (this can also be done from `.bashrc`):\n\n```sh\n$ CD_EXTENSIONS=all\n$ . cd\n```\n\nAlternatively:\n\n```sh\n$ CD_EXTENSIONS=(traverse history ssh s3fs archive hdfs encfs dev loop)\n$ . cd\n```\n\nAlternatively:\n\n```sh\n$ . cd                      # enables extensible cd\n$ . cd-traverse             # enables descendant/ancestor traversal\n$ . cd-history              # ^, ^^, ^n, -n, ^regexp\n$ . cd-ssh                  # does nothing unless you have sshfs\n$ . cd-s3fs                 # does nothing unless you have s3fs\n$ . cd-archive              # does nothing unless you have archivemount\n$ . cd-hdfs                 # does nothing unless you have hadoop-fuse-dfs\n$ . cd-nfs                  # does nothing unless you have mount.nfs\n$ . cd-encfs                # does nothing unless you have encfs\n$ . cd-dev                  # enables automounting for /dev/ entries\n$ . cd-loop                 # enables mounting for loopback files\n$ . cd-missing-mkdir        # mkdir -p if you cd someplace nonexistent\n```\n\nYou can see the patterns that are handled by running `cd --patterns`. (This can\nbe useful if you want to find out which ones are ignored due to unmet\ndependencies.) Anything that isn't a pattern is treated like a regular\ndirectory change.\n\n**Be sure to initialize this script after RVM.** RVM redefines `cd`, clobbering\nany existing redefinitions. This script, on the other hand, preserves RVM's\n`cd` redefinition while adding behavior of its own.\n\nSome of `cd`'s extensions store state and/or create temporary mountpoints in\n`~/.cd`, which it automatically creates.\n\n## `mkdir` functionality\n```sh\n$ . cd-missing-mkdir\n```\n\nSourcing this script causes `cd` to create directories that don't exist. Any\nleaf directory created by `cd` will be removed upon leaving if it is empty and\nno process is using it. So, for example:\n\n```sh\n$ ls\nfoo  bar\n$ cd BOOYAH\n$ cd ..\n$ ls\nfoo  bar\n$\n```\n\nAt this point `cd` will create but not delete parent directories:\n\n```sh\n$ ls\nfoo  bar\n$ cd bif/baz/bok\n$ cd ../../..\n$ ls\nfoo  bar  bif\n$ ls bif\nbaz\n$ ls bif/baz\n$\n```\n\n## Authors\n- Spencer Tipping [spencertipping](https://github.com/spencertipping)\n- Vivien Didelot [vivien](https://github.com/vivien)\n\n## License\nMIT as always.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspencertipping%2Fcd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspencertipping%2Fcd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspencertipping%2Fcd/lists"}