How do I execute a command every time after ssh'ing from one machine to another?
e.g
ssh mymachine
stty erase ^H
I'd rather just have "stty erase ^H" execute every time after my ssh connection completes.
This command can't simply go into my .zshrc file. i.e. for local sessions, I can't run the command (it screws up my keybindings). But I need it run for my remote sessions.
-
Assuming a linux target, put it in your
.profilesomeguy : Won't work -- see my updated question info. -
If you're logging into a *nix box with a shell, why not put it in your shell startup?
.bashrcor.profilein most cases.someguy : Won't work -- see my updated question info.Ken Gentle : Fair enough - I'd go with @geocar's suggestion then. -
You can put something like this into your shell's startup file:
if [ -n "$SSH_CONNECTION" ] then stty erase ^H endThe
-ntest will determine ifSSH_CONNECTIONis set which happens only when logged in via SSH. -
Try adding the command below the end of your ~/.bashrc. It should be exited upon logoff. Do you want this command only executed when logging off a ssh session? What about local sessions, etc?
trap 'stty erase ^H; exit 0' 0You probably could setup a .logout file from /etc/profile using this same pattern as well.
-
Put the commands in
~/.ssh/rcRobert Gamble : +1, I knew there had to be a better way to do this.Ken Gentle : +1, didn't know this existed.
0 comments:
Post a Comment