os-patches icon indicating copy to clipboard operation
os-patches copied to clipboard

$_ doesn't work

Open elementaryBot opened this issue 7 years ago • 6 comments

$_ does not work in Terminal 0.4

Steps

  1. cd Downlaods
  2. cd $_

Error Message

bash: cd: __bp_preexec_invoke_exec: No such file or directory

Launchpad Details: #LP1628992 Jahdo Lee - 2016-09-29 16:21:55 +0000

elementaryBot avatar Apr 26 '17 17:04 elementaryBot

Hello,

Can you clarify what is the expected behavior?

Launchpad Details: #LPC Zisu Andrei - 2016-09-29 19:07:08 +0000

elementaryBot avatar Apr 26 '17 17:04 elementaryBot

$_ means the last used file path.

for example,

ls wordpress-4.6.zip && unzip -l $_

same as

ls wordpress-4.6.zip && unzip -l !#:1

Launchpad Details: #LPC Jahdo Lee - 2016-09-30 06:12:01 +0000

elementaryBot avatar Apr 26 '17 17:04 elementaryBot

Apologies I have not asked this before, but can you give an example of a terminal in which this works?

Launchpad Details: #LPC Zisu Andrei - 2016-10-01 21:05:38 +0000

elementaryBot avatar Apr 26 '17 17:04 elementaryBot

P.R.C National Day 10.1 - 10.7

it works in Gnome-terminal in Ubuntu 16.04, Terminal/iTerm2 in Mac OS X

Oh, it occurs to me that I use zsh, not bash, in there environments.

Launchpad Details: #LPC Jahdo Lee - 2016-10-10 05:54:07 +0000

elementaryBot avatar Apr 26 '17 17:04 elementaryBot

$_ is available in bash as documented here.

That said, I don't think this is a problem with the terminal app, but rather with the "bash-preexec" script included with elementary (/etc/bash-preexec). This also appears to be fixed in more recent versions of 'bash-preexec'.

ghost avatar May 05 '17 20:05 ghost

It looks like we added bash-prexec in a patch here: https://github.com/elementary/os-patches/commit/eb320175fcb1c3191c413a6b9e0b5764262ebe76

So, moving to os-patches since that's where this file comes from. This patch probably needs to either be dropped completely or just rebased on the upstream version as implied by this tweet

danirabbit avatar Dec 05 '19 20:12 danirabbit

Linking the upstream issue here: https://github.com/rcaloras/bash-preexec/issues/39

We can either cherry-pick the upstream fix or rebase on latest released upstream version, but I think the latter is better because our bash_preexec is old (0.2.1) and it might be impossible to simply cherry-pick the fix to our version.

ryonakano avatar Aug 17 '24 23:08 ryonakano

Closing as fixed in #295

ryonakano avatar Aug 18 '24 21:08 ryonakano