-1

I love "ALT ." to re-use the last argument of the previous command on the linux command line.

Unfortunately PyCharm's terminal does not support this feature: IDEA-155783

Since JetBrains ignores this issue since five years, I think it is time to look for a work-around.

Is there a way to get "ALT ." working in PyCharm's Terminal?

Environment: Ubuntu 20.04

guettli
  • 25,042
  • 81
  • 346
  • 663
  • I looked into this, assuming your terminal is launching the standard "cmd.exe" you can execute a "batch-file" right when you are starting (by setting `path\to\cmd.exe script.bat` in the IDE). Problem then is that setting a keyboard-shortcut from that batch-file that would execute a script every time you press `Alt+dot` isn't easy given it's Microsoft. Probably the best choice here would be using [AutoHotKey](https://stackoverflow.com/a/133332) to launch with the terminal, setting the key-binding, and then you'd have `Alt+dot` working like you want it... – bad_coder Feb 10 '21 at 06:41
  • @bad_coder I have not used Windows since 20 years. Does `Alt .` re-use the last argument on windows, too? – guettli Feb 10 '21 at 17:21
  • I think the question could use some clarification, for example [you can choose the terminal that you want to use in PyCharm](https://www.jetbrains.com/help/pycharm/terminal-emulator.html#configure-the-terminal-emulator) but the question doesn't say exactly what shell you want (it didn't say OS either). I'm surprised this is an issue, because if you look at the configuration what the terminal does is launch the shell you selected (maybe wrapped in some launching process, but the shell executable nevertheless). – bad_coder Feb 10 '21 at 17:29
  • Did you go to `Settings` `>` `Tools` `>` `Terminal` and tried the options "Override IDE shortcuts" and "shell integration" (see [this description of options](https://www.jetbrains.com/help/pycharm/settings-tools-terminal.html)) because that should be enough to get the `Alt+dot` to work. – bad_coder Feb 10 '21 at 17:37
  • @bad_coder I deactivated "Override IDE shortcuts", but this did not change. `ALT .` does still not insert the last argument of the last command. – guettli Feb 11 '21 at 09:54

1 Answers1

0

It's not quite the same, but if you're using the default bash shell, you can use either $_ or !$

In pycharm's terminal window:

$ ls /dev/null
/dev/null
$ echo "stackoverflow" > !$
echo "stackoverflow" > /dev/null

Bash has a ton of built-in history recall features: https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#History-Interaction

I'm sure most other shells do as well.

ibuntu
  • 41
  • 5