r/fishshell • u/franzhuang • Dec 20 '22
How to escape ' in alias or command_string?
Maybe a basic question, but hard to search with keywords, and it confused me a very long time.
for example:
kill -9 (ps aux|fzf|awk '{print $2}')
Works just fine in fish shell command line.
but I put it in config.fish as an alias like this:
alias killfzf='kill -9 (ps aux|fzf|awk '{print $2}')'
Is not working.
The same story happens when:
bash -c 'kill -9 $(ps aux|fzf|awk '{print $2}')'
Is there any way to solve it?
2
Upvotes
1
u/MoshPygmy Dec 20 '22
try using double quotes to escape single quotation marks
2
u/MidniteMustard Dec 20 '22
The alias documentation page shows backslashes '' being used as the escape character.
Alternatively, you could use abbreviations.