Score:0

Create a alias using ls | grep | xargs xdg-open

jp flag

I'm trying to create a alias combining ls | grep | and xargs xdg-open.

This is what I've tried so far. Not sure why it is not working.

alias lso='ls | grep "$1" | xargs -I {} xdg-open {}'
alias lso='ls | grep "$@" | xargs -I {} xdg-open {}'
alias lso='ls | grep | xargs -I {} xdg-open {}'

The idea is be able to to this in the terminal:

$ lso example

The interesting thing is that I can use this using the terminal:

$ ls | grep example | xargs -I {} xdg-open {}'

Does anyone have any work around that?

Esther avatar
es flag
if you need to take arguments, you need a function, not an alias. aliases literally do text substitution, nothing fancier. The only way this would work is if your arguments can go at the end of the line
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.