Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
7
Help us understand the problem. What is going on with this article?
@ymko

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

More than 3 years have 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
7
Help us understand the problem. What is going on with this article?
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.
Sign Up
If you already have a Qiita account Login
7
Help us understand the problem. What is going on with this article?