b-ryan / powerline-shell

A beautiful and useful prompt for your shell
MIT License
6.22k stars 745 forks source link

Auto append of shellcode for different shells #308

Open iilonmasc opened 7 years ago

iilonmasc commented 7 years ago

Small suggestion: Maybe check the current used shell with echo $0 and add the needed code to the respective file after install

UPDATE: In Python you could simply get the current shell with

import os

print(os.environ['SHELL'])
jceaser commented 7 years ago

I get bash despite the fact that I'm in fish. Do you want the current defined shell or the active running shell?

iilonmasc commented 7 years ago

I was thinking of the active running shell if you install it for the current user. Would be the most obvious decision, I guess

b-ryan commented 6 years ago

This is not a bad idea - I have long been thinking about adding a command to this project to help with installation and validation. Primarily the reason I want to do this is to, if possible, check that one of the supported fonts is properly installed since I get many issues that would be solved if this could be automated.

Rather than try to guess the shell, which I think can be difficult and error-prone, this setup script could just look to see if you have a bashrc, fish config, etc and ask the user whether they want to update those. I certainly would not want to do anything without asking the user first anyway.

iilonmasc commented 6 years ago

You would need to ask for every shell though, also it seems echo $0 returns the shell which issued the command, maybe you can use the subprocess but I am not sure whether python will return the shell or just python

b-ryan commented 6 years ago

Yeah but if that were a bad UX, you could just ask the user which shell to configure or take it as an argument. Like powerline-shell configure --bash or something. I just have a feeling any automated solution will have issues on other systems and there will be a bunch of issues when it doesn't work.

As a compromise solution, it could guess, but ask the user. If the user says no, provide a list they can select from.

iilonmasc commented 6 years ago

That sounds better, yes.

So something like

powerline-shell configure --shell=bash
# or
powerline-shell configure --bash

Would be the best approach