/etc insider

since 1999 (and still editing)

Do you comment your interactive shell?

| Comments

Another shell trick I’d like to share is commenting. Why one would need this while in interactive mode? Well, real world isn’t perfect, and sometimes you might need to log into some remote system using its new IP-address – say, during service migration from old to new one. DNS hasn’t been updated yet, it’s too early. So, what are you up to — remembering all those digits? Forget it! ;) (You will anyway) :)

Long story short – with bash it’s really easy, just put # after command in question and that’s it. But zsh won’t let you go this way. So, it’s time to recall we have something more universal — a colon: :. In fact it stands for “no operation”, but it’s useful anyways:

1
2
3
4
% type :
: is a shell builtin
% ssh nowedontuserootforssh@192.168.4.2 ;: Host we migrate to
^C

Should you need to repeat the command, Ctrl_R and interactive search for ‘Host we migrate to’ would retrieve it for you both in zsh and bash.

Comments