Score:0

Failed run a user's alias inside bash CLI

us flag

How can run a user's alias

$ grab 'man'

but as to do in a CLI

$ bash -c "grab 'man'"
bash: line 1: grab: command not found

Please show the fixing way

ru flag
where is the user's alias defined? If it isn't in their `.bashrc` it won't be available in `bash` calls. And if they are not defined in your current session you can't use them. (every alias is session-only and has to be reloaded on each Bash session)
hr flag
`bash -c` invokes a non-interactive shell iirc, so aliases won't be expanded and (at least with the default .bashrc) their definitions will likely be skipped if they follow the "If not running interactively, don't do anything" check
Score:0
cn flag

An alias is for interactive use only. It do not take effect when you attempt to run them from the non-interactive shell you initiate with the bash -c command.

There are two approaches if you want a custom command to be available in a non-interactive shell.

Alternative 1. Create a script in a directory in the PATH

For example, create a script ~/.local/bin/grab that executes the long command. The directory ~/.local/bin/ is automatically included in the PATH when it exists, so you can run this script by simply typing grab. It is also available in a non-interactive subshell.

Alternative 2. Create a function in your shell's profile config file

For bash, you would define a function in your ~/.profile configuration file:

grab () {
<actual code>
}

~/.profile is read when you log in. From now on, grab will be like an internal bash command, and can be accessed by simply typing grab. It is also available in a non-interactive subshell.

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.