Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

zsh: alias with $(command) parameter

Tags:

zsh

My Goal

I'm using the following command quite frequently:

vim $(fzf)

It uses fuzzy find to search a list of files, and then open the highlighted one in vim.

enter image description here

My Problem

I would like to alias vim $(fzf), but when I add alias v="vim $(fzf)" to .zshrc, fzf is executed whenever I open a new shell.

My Question

How do I set zsh to execute the $(command) only when the aliased command is executed?

like image 868
Adam Matan Avatar asked Nov 09 '17 20:11

Adam Matan


1 Answers

Simply replace

alias v="vim $(fzf)"

With

alias v='vim "$(fzf)"'
like image 100
Adam Matan Avatar answered Nov 05 '22 06:11

Adam Matan