pickhardt / betty

Friendly English-like interface for your command line. Don't remember a command? Ask Betty.
2.61k stars 215 forks source link

Go home doesn't actually work #177

Closed fuzzygroup closed 6 years ago

fuzzygroup commented 8 years ago

In the fun module it appears as if go home should work but it actually doesn't because the command isn't executed.

matthewsedam commented 7 years ago

It appears that the command is executed, but it is executed in the betty process. So, if you execute "betty go home" in bash, for example, betty runs the command and changes the directory but the directory in the parent bash process is not changed as "cd ~" is not ran through bash. I do not believe there is a way around this as bash would have to listen for a signal from betty.

jonmarkprice commented 7 years ago

I think the only way around this would be for betty to replace the parent process (i.e. the shell) with a new process. After executing cd ~, we'd have to call exec bash. However, not everyone uses bash, so we'd need to detect which shell they were using when they launched betty.

Something like this:

#!/usr/bin/ruby
parent = Process.ppid
shell = %x{ps -q #{parent} -o comm=}
exec("cd ~; exec #{shell}")

will open a new instance of the correct shell at the user's home directory, but it will still be running atop the old shell. Thus if you type 'exit', you will appear back in the old instance of bash, etc. Also if you click to close the console window it will warn you about running child processes. The only way that I can think of to get around this would be to open a new terminal window (e.g. x-terminal-emulator on Linux) but this will cause the new window animation to show up and will clear the screen and lose recent command history. Thus I don't think there is a good solution to this problem without making betty a shell in its own right. So I think the "go home" functionality should be removed.

matthewsedam commented 7 years ago

I agree.