chrissimpkins / glue

Glue is a plugin that joins your shell to Sublime Text in quasi-perfect harmony.
http://gluedocs.readthedocs.org/
MIT License
253 stars 10 forks source link

Does it Read .bashrc? #12

Closed brmullikin closed 10 years ago

brmullikin commented 10 years ago

I wonder if glue supports .bashrc (or .bash_profile on mac)?

Perhaps I need to set the path somewhere?

I didn't see anything in the documentation about it, so I thought I would ask.

Cheers, and thanks for the wonderful plugin!

chrissimpkins commented 10 years ago

For Mac users, it queries for the standard output from the command:

bash -ic 'echo -n $PATH'

On Linux, Python returns the proper PATH with the os module:

os.environ['PATH']

It will automatically initialize your PATH with one of those two approaches depending on your system.

You can set a PATH in Glue without modifying your system PATH in any of your shell startup files using these instructions in the docs. It's simply a line of JSON in the Glue settings file.

Let me know if that addresses your question. Glad to hear that it's been helpful!

brmullikin commented 10 years ago

I had meant a path to the bash file.

I had hoped to load up some various environment variables and aliases.

chrissimpkins commented 10 years ago

I think I understand. No, Glue does not load the .bashrc file and is not initialized with the bash settings (with the exception of $PATH). You can access your system environment variables through Glue:

echo $USER

but not the aliases or user generated variables in startup files. I will play around with this a bit. It would be a nice way to maintain existing aliases. The numerous shell types and differences between the initialization/startup sequence for Mac and Linux versions of bash will make it somewhat difficult to support this.

In case you weren't aware, I did build in a Glue 'alias' type that is documented here. It would mean copying over your existing aliases, but should function identical to bash aliases (albeit with glue in front of the term that you use for the alias). They also allow you to add template tags for additional command line arguments, clipboard data, and your current working directory should you need any of that information in the extension/alias.

brmullikin commented 10 years ago

Hi Chris,

Thanks for the explanation. I will certainly check out the Glue aliases.

Cheers,

Ben

chrissimpkins commented 10 years ago

I'll take a look at the bashrc reads. bash is so widely used on Mac and Linux that it may be worthwhile finding a way to at least optionally build this in. Thanks again for the feedback. Really appreciate it. Have fun with Glue!

kaushikgopal commented 10 years ago

yeah having glue mimic my actual terminal environment (with the host of aliases/functions etc.) loaded from a bashrc file would be amazing

N4M3Z commented 9 years ago

+1

dnut commented 8 years ago

This is actually pretty easy to implement as a user. Of course, one way would be to convert your aliases and functions to json, which is also easy, but that introduces the problem of having to maintain two separate files, so it's far from ideal. If you just want to use your bashrc file in Glue, complete these steps:

alias foo="echo 'bar'"    # remove
foo() { echo 'bar'; }     # add
[[ $- != *i* ]] && return
"rc": ". $HOME/.bashrc; {{args}}"

Whenever you want to call a function from your bashrc in Glue, use a command like this:

glue rc [command]

Don't expect everything to work perfectly, but most things should be fine. If you have something that requires user input, get creative.