Git Product home page Git Product logo

Comments (8)

vyasgiridhar avatar vyasgiridhar commented on May 15, 2024 1

But can you change

cmd := exec.Command(shell, "-l", "-i", "-c", "which "+a)

to

cmd := exec.Command(shell, "-l", "-i", "-c",a)

would directly spawn the alias process.

from noti.

variadico avatar variadico commented on May 15, 2024

Could you post more information about this? I wasn't able to reproduce this.

I set this in my ~/.zshrc.

alias n="noti"

Then I ran source ~/.zshrc.

I was able to run n -V alex successfully.

from noti.

simioes avatar simioes commented on May 15, 2024

I am not talking about set "noti" as an alias. For example, in osx:

alias speak_hello=' say "hello"'

noti speak_hello give an error. No detailed information, but the command in alias does not run.
Try that.

from noti.

variadico avatar variadico commented on May 15, 2024

Ah, yes.

In v2, you now see more information.

image

Currently, noti assumes utility is an executable in your $PATH. It didn't evaluate your alias. Interestingly, the time command does evaluate aliases, so, yes: this is a bug.

from noti.

variadico avatar variadico commented on May 15, 2024

Wait. I just realized time isn't /usr/bin/time in my shell. Running /usr/bin/time speak_hello also results in the same behavior as noti. I'm guessing the reason it worked before was because Zsh knew how to expand the alias when it ran its version of time.

Getting this behavior right seems trickyβ€”and doing it in a way that works across different shells seems even more difficult.

Technically, you can get this to work in bash, version 3.2.57, like this.

shopt -s expand_aliases
alias speak_hello='say "hola"'
noti $(speak_hello)

I'd recommend to avoid doing this though. It seems like most apps can't handle expanding alias arguments.

from noti.

variadico avatar variadico commented on May 15, 2024

Hi, @vyasgiridhar, @chmaynard, and @simioes.

I think I might have finally found a solution to this, that's not too crazy. (No regexp.)

cd github.com/variadico/noti/cmd/noti
git fetch --all
git checkout expand-alias
go install

Then try running noti on some shell alias.

noti speak_hello

Can anyone else verify this works? I tried this on macOS Sierra with ZSH. It would be awesome if someone could test on other platforms and shells. ✌️

Thanks!!

from noti.

vyasgiridhar avatar vyasgiridhar commented on May 15, 2024

It works on bash in Arch linux. πŸ‘

from noti.

variadico avatar variadico commented on May 15, 2024

Merged the alias change to dev, 1598292.

@vyasgiridhar, I liked your change, but I kept it the way I had it because executing the alias in the subshell caused arguments passed to aliases to be escaped.

$ which findhere 
findhere: aliased to find . -iname
$ noti findhere '*.go' # <- Expanding
$ noti findhere '\*.go' # <- Executing directly

Maybe we can optimize this later.

from noti.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.