Giter Club home page Giter Club logo

marcopolo's Introduction

marcopolo

NOTICE: Use autojump to achieve much much more powerful directory switching.

NOTICE: This repository is out of maintenance, please check ghrtools for the latest updates.

Our Philosophy: Optimize for the common case!

save current working directory and cd you back anytime, anywhere, even if the terminal is restarted.

image-20220910142913316

marco and polo are two shell scripts, polo must be executed by source polo to work correctly.

Whenever you execute marco the current working directory should be saved, then when you execute polo, no matter what directory you are in, polo should cd you back to the directory where you executed marco.

marco:

#!/bin/bash
pwd > ~/study/mit_missing/shell_lec2/exer2/lastpolo.log
echo "Current working directory saved. Use polo to cd you back."

polo:

#!/bin/bash
lastpath=$(cat /home/geng/study/mit_missing/shell_lec2/exer2/lastpolo.log)
echo "$lastpath"
cd "$lastpath" 

.bashrc:

alias polo='source /home/geng/study/mit_missing/shell_lec2/exer2/polo'
PATH=$PATH:/home/geng/study/mit_missing/shell_lec2/exer2
export PATH

PS: if you just want to go back to the last working directory, just use cd -

TODO

Support arguments, then users can use sth like marco [-ID] and polo [-ID] to save and jump between many working directories, use marco -l to show all saved directories and their ID. [Aborted. plz use autojump instead]

Bonus

More about Directory Navigation

So far, we have assumed that you are already where you need to be to perform these actions. But how do you go about quickly navigating directories? There are many simple ways that you could do this, such as writing shell aliases or creating symlinks with ln -s, but the truth is that developers have figured out quite clever and sophisticated solutions by now.

As with the theme of this course, you often want to optimize for the common case. Finding frequent and/or recent files and directories can be done through tools like fasd and autojump. Fasd ranks files and directories by frecency, that is, by both frequency and recency. By default, fasd adds a z command that you can use to quickly cd using a substring of a frecent directory. For example, if you often go to /home/user/files/cool_project you can simply use z cool to jump there. Using autojump, this same change of directory could be accomplished using j cool.

More complex tools exist to quickly get an overview of a directory structure: tree, broot or even full fledged file managers like nnn or ranger.

marcopolo's People

Contributors

exaithrg avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.