It remembers directories you cd to, ranks them according to frecency (frequency + recency) and allows you to change to one of the remembered paths using some part of its name.Īfter having cd'ed to a directory at least once you can do e.g instead of: $ cd ~user/very/long/path/with/many/subfolders/ from /home/thina/teams/td/tech/app/release/apks/com.acme/v1, running cd release beta goes to /home/thina/teams/td/tech/app/beta/apks/com.acme/v1.Īs I already answered on a related question on UnixSE, I use a script called z for this. In particular the two-argument form of cd lets you conveniently change to another directory with a similar name, e.g. Some of them can be emulated by writing functions that do the same job. Zsh has a few nice features that bash doesn't have. You can set a variable to a directory name and then change to it with $foo. However be warned that I've never found a situation where CDPATH was actually handy. If you frequently change to subdirectories of a particular directory, and these subdirectories have rather unique name, add them to the CDPATH variable. The builtin dirs lists the directory stack (I find dirs -v more readable). You can memorize directories on a stack with the builtins pushd and popd. The autocd option doesn't make - run cd - but you can define an alias or function for that. If you're navigating between two directories, you can toggle between them with cd -, which goes to the previous working directory. For example, you just need the two-character command. ![]() Turn on the autocd option ( shopt -s autocd), so that you don't have to type cd. Has moved you to apks in td, rather than some other apks under a different tree. I would recommend it instead of having your own script since it is well maintained, distributed for Ubuntu, and has other neat features, such as jump to child. apks if you went there more times than to. ![]() Note that using any part of the path works, as long as it's the highest on the list: ![]() You can use the shortcut j to move there quickly, regardless of which directory you're currently in: It's basically what has built, with a few extra options.Īfter you cd a few times to a directory (even once suffices):Ĭd /home/thina/teams/td/tech/app/release/apks Works by maintaining a database of the directories you use the most from the command line (Directories must be visited first before they can be jumped to.) I am surprised no one has mentioned autojump yet which UPDATE: There's an even more powerful tool than autojump: fasd, but I am not familiar with it. Example: $> cd /etc/lightdmĪnd here is the function itself: bookmark() Here's how it works: it saves your current folder to some file, and then you can cd to a specific directory based on the line number in that file. To return to /home/thina/teams from apks you would do goup 6Īnother small function that i came up with, but never used as much is bookmark function. ![]() For example, APKS="/home/thina/teams/td/tech/app/release/apks"Īs for going up x number of directories, I have this function defined in my. Using these tips together can make traversing directories with cd far less painful.įor long directory names, use variables with full path. For instance, if you had typed cd /home/thina/teams/td/t then pressed Tab, the word tech would be filled in for you, so long as there were no other files or directories in the td directory that started with the letter t.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |