Search code examples
bashgitcurlterminalprompt

How to enter token without leaving history in terminal?


I'm trying to call GitHub API in the terminal. It requires to input the username and token. Token are entered with plain text. For security purposes, I don't feel like leaving some token history on this public computer.

How can I enter the token without leaving history?


Solution

  • If $HISTCONTROL is set to ignorespace or ignoreboth (which is the default):

    You can type a space before the command to prevent it from being recorded in the history.

    See also: https://unix.stackexchange.com/a/115922/198262

    If you need to use this command several times, you can first store the token in a variable and prefix the variable assignment with a space and then just use the variable in your commands without having to remember the space. You could also disable the history for the current session entirely using set +o history.