2

I'm using the rlwrap utility inside the following shell alias:

alias gp='rlwrap git push'

The purpose of this gp alias is to be able to use basic line editing commands such as C-a or C-e to get to the beginning or end of the command line, while I'm using the git push command.

I've also configured rlwrap to write the input history of every command I use it for, in a dedicated file (~/.config/rlwrap/<command>_history):

export RLWRAP_HOME="${HOME}/.config/rlwrap"

When I use the gp alias, I have to give my credentials, username and password, and rlwrap saves them in ~/.config/rlwrap/git_history.

Is it possible to let rlwrap save the input history of all the commands I use, except the passwords, like for example in the gp alias?

3
  • 2
    Can't you set up ssh keys for the remote git server? Jul 2, 2017 at 12:27
  • @glennjackman Thank you very much for your suggestion. I don't know much about git and ssh, but I will look into this as soon as I can.
    – user852573
    Jul 2, 2017 at 12:30
  • 2
    For example, in github, go to your account settings and you'll see a section for "SSH keys". You can create a public/private key pair with the ssh-keygen command Jul 2, 2017 at 12:41

3 Answers 3

3

I think I've just found a way to prevent the current input line to be saved. From man rlwrap:

SPECIAL KEYS
   Control + O
          Accept the current line, but don't put it in the history list. This action has a readline command name
          rlwrap-accept-line-and-forget

So, instead of validating a line with Enter, if I do it with C-o, it shouldn't be saved.


Maybe I could also use the -g option, but I'm not sure I could build a regex describing a password, without describing an ordinary input at the same time:

       -g, --forget-matching regexp
          Forget  (i.e.  drop  from history list) all input lines that match the POSIX 1003.2 regular expression
          regexp.  The match is always case-insensitive. regexp may be an ordinary string. For more about  regu‐
          lar expressions, see  regex (7)
2

I have to give my credentials, username and password, and rlwrap saves them in ~/.config/rlwrap/git_history

Are you certain rlwrap indeed saves your password in its history file? By design, input that isn't echoed back is never put in the history list (in such a case, rlwrap will echo your keystrokes as ****) I checked it, and, on my system at least, this is what happens with git push as well.

If you really see your password in the history file, please file a bug at rlwraps GitHub site

1
  • Thank you very much for your comment. I probably made a mistake and pasted my password in the username field, because I can't reproduce anymore. Now, it only saves the username, except if I use c-o. If I find a bug I will report it on github next time, but I don't think there's any problem, just a wrong manipulation on my part.
    – user852573
    Jul 18, 2017 at 11:21
1

You can override the default history file with rlwrap's -H option.

e.g. alias gp='rlwrap -H /dev/null git push'

1
  • Newer (>= 0.43) rlwrap may notice that /dev/null is not owned by the current user, and complain (here's why). One can silence those complaints with the -n (--no-warnings) option.
    – Hans Lub
    Jul 23, 2017 at 22:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .