4
I would like to configure my PuTTY session in such a way that I could login to a remote host, and (a) start bash (b) change the PS1 variable (prompt content) (c) continue work in the session as normal.
I tried:
- Connection -> Data -> Environment variables [does not work; session looks as if (b) had not been executed] AND
- Connection -> SSH -> Remote command: PS1="some stuff" [the window with the session opens for a fraction of sec, and then it closes]
Any ideas? I had had a look to some similar questions in the forum, but did not find anything helpful.
More generally: I log in into a host where many users log in as a single user, and thus they all share the 'settings' of the single user. I look for a method of forcing PuTTY into changing some of these settings temporarily (i.e., such that they would be time limited to the session that I open using PuTTY). Sort of running personal version of .bashrc within the session. Hope this makes sense.
I added a note to the original question. Problem is that the .bashrc is shared among all the users who log in, and I cannot modify it... I could create a personalized .bashrc-my, but then I still don't know how could I call it when logging in with PuTTY. – Simon Righley – 2014-01-29T17:42:04.477
@SimonRighley OK, can you set the server to allow setting of env variables as described in the post I linked to? You could always just add an alias to the shared .bashrc:
alias ps1="PS1='some stuff'"
and then run the alias each time you log in. – terdon – 2014-01-29T17:54:15.400@SimonRighley see updated answer for another solution. – terdon – 2014-01-29T18:04:37.040
Fantastic! That did the trick :) Thank you so much! Spent so much time trying to figure this out... Can I now define all sort of aliases, variables and what not in the ~/.myps1 (I called it ~/.bashrc-my_name), and the protocol you described will respect the settings from the default .bashrc, and after that (on top of it?) it will read in all that I'll define in bashrc-my_name? – Simon Righley – 2014-01-29T18:17:10.757
1@SimonRighley yup. As long as you source the global
.bashrc
first, anything you do after that will supersede any settings you have in.bashrc
. Settings in.bashrc
that are not overwritten by commands in.bashrc-my_name
will persist. – terdon – 2014-01-29T18:18:03.570One more problem... Some of the environment variables are lost on the way somehow. That is to say that when I 1. login as before, run 'bash', and see for the 'env' I see a much shorter list of variables there as compared to the procedure that you suggested (that is login in with --rcfile, and seeing for 'env' subsequently). Any ideas? – Simon Righley – 2014-01-29T18:37:13.043
@SimonRighley yes, I had already edited my answer to have it also source the global
/etc/bash.bashrc
file. Try with that added. – terdon – 2014-01-29T18:39:56.980Unfortunatelly, there is no such file there... Might be related to the fact that's solaris? I also sourced .kshrc and .cshrc but it didn't help. – Simon Righley – 2014-01-29T19:01:40.373
@SimonRighley in any case, I'm being silly, you want the
/etc/profile
since this is a login shell. See updated answer. – terdon – 2014-01-29T19:03:12.900Cool! sourcing /etc/profile, together with .kshrc and .cshrc produces the same result for 'env' as in the standard way. I still see some error messages (failed to remove/create some files), but maybe it won't cause any malfunctioning. Thanks a million, man! Have a great day :) – Simon Righley – 2014-01-29T19:38:02.037