Giter Club home page Giter Club logo

Comments (4)

technocake avatar technocake commented on June 2, 2024 1

The main reason for why you need start_goto sourced is to be able to run goto cd <magicword> and then have the terminal change working directory - as you would expect. The other reason is to setup auto completion for goto. (this must be done each time a terminal starts, as far as I know).

In order to change the working directory of the parent shell, i.e, your terminal, running a script simply will not work. It changes the working directory of the forked process, but not the shell you are in. Sourcing runs the script as it would if you typed the commands one by one - and so this is ultimately how goto circumvents this issue of being able to change working directory of the shell calling goto.

However, we discussed this - should the setup script touch your ~/.bash_profile without warning?
The thought behind it doing that was to make setup a no-hazzle time and make goto work straight away. However it assumed every system would have a .bash_profile and that was the main entrypoint. It is a naïve assumption.

I think the best solution could be to ask the user when goto installs. To give a prompt asking whether or not to append to ~/.bash_profile . If the user don't want to, because they know they have a different setup - they could be informed by what to do to make it work (i.e append it manually somewhere them self).
I guess a reasoning for why this must be done also should be in place.

Further discussion could go on to whether or not find ~/.bash_profile -- I guess I'll have to read up on the bash startup files hierarchy.

from goto.

technocake avatar technocake commented on June 2, 2024

Look at bin/goto - https://github.com/technocake/goto/blob/master/bin/goto#L7-L11 - for how the cd-technique is implemented today.

And then look at the bash function named goto in start_goto - https://github.com/technocake/goto/blob/master/bin/start_goto#L47-L51

So the start_goto script is registering the bash function named goto, which then will source bin/goto each time you type goto in the terminal.

Chain of events:
source start_goto --makes goto function available--> goto(function) sources --> goto(script)

from goto.

technocake avatar technocake commented on June 2, 2024

Proposed fix is in pull request #12

from goto.

technocake avatar technocake commented on June 2, 2024

Install script now asks the user before it appends bash_profile

from goto.

Related Issues (20)

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.