Help us understand the problem. What is going on with this article?

bashで言うところの!$はfishではどうすればよいか

More than 1 year has passed since last update.

mkdirでディレクトリを作成して、そのディレクトリへ移動したいときに

$ mkdir tmp
$ cd !$

とする。
ところが、fishでやると、

> mkdir aa
> cd !$
Expected a variable name after this $.
fish: cd !$
          ^

さて困った。
ちなみに!$はbashで言うところの最後の引数を示す。

こたえ

そのままズバリの質問をしている人がいたのでご紹介。
.config/fish/config.fishに以下を書いて、端末を起動しなおせばよい。

command line - What is the equivalent of bash's !$ and !! in the fish shell? - Super User

適当訳。
fishでは残念ながら!$に該当するものが無い。
メーリングリストにperfect answerがあったんで貼っとくね!

~/.config/fish/config.fish
function bind_bang
    switch (commandline -t)[-1]
        case "!"
            commandline -t $history[1]; commandline -f repaint
        case "*"
            commandline -i !
    end
end

function bind_dollar
    switch (commandline -t)[-1]
        case "!"
            commandline -t ""
            commandline -f history-token-search-backward
        case "*"
            commandline -i '$'
    end
end

function fish_user_key_bindings
    bind ! bind_bang
    bind '$' bind_dollar
end
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした