New answers tagged

0

Ok, found it... The /etc/profile has a call to another script buried in conditions: test -d $SITE -a -d $SITE/$VER -a -e $SITE/$VER/site_config && . $SITE/$VER/site_config which in turn opens a text file with key=value pairs and makes aliases from this list. And that list has a bad pair... Our admins are such strange people...


2

Yes, the order is important: whichever one is first in the output of type is the one that will be executed. So, in your case, pandoc would run the alias, /usr/bin/pandoc, and gsettings would run /usr/bin/gsettings. I can't actually find where this behavior is documented, where it is stated that the first result of type -a is the one that will be executed, ...


1

As the answers to the other questions indicate: Aliases are just not good at handling parameters. You can even see that: param=foo; do something with "$param" That is how parameters work: First (both in time and in the command line) you set them, then you use them. In contrast to that: <alias string with several commands to be expanded> <...


3

If you must use alias, here's one that works by using -t to specify the destination directory before the actual argument for the file being moved: alias my-alias="mkdir \$(date +%F); mv -t \$(date +%F)" Works on Linux, I don't have a MacOS machine to test with though.


3

Use a function instead of an alias. This is pretty much always the answer if you run into trouble getting an alias to work. Especially if you're trying to use arguments (e.g. $1), since aliases don't really take arguments. Also, you should pretty much always put double-quotes around parameter and variable references (i.e. "$1" instead of just $1). ...


-1

You need to create a function. mkdir -v -p '$(date +%F)-List' will only get evaluated at the time the alias was created


1

Not very official but you could create a user with the other name but with the same settings (UID, GID, $HOME, password). That would allow you to use e.g. ~jsmith and ~johnsmith.


2

There might be a workaround. In bash, when an alias expansion ends with a space, the next word is also considered for expansion. So if I had: alias foo='echo ' bar=hello Then foo bar would result in echo hello being run: $ foo bar hello With this, you can use an alias for the grp function to have its first argument be considered for alias expansion, and ...


0

You might try: grp() { local grep_pattern=$1 shift # remaining args are the command: "$@" | grep "$grep_pattern" | less } And invoke it like: grp nvidia pac -Q


1

You need to use command substitution in your alias: alias zathura='zathura -e $( tabbed -c ) & disown' Note that the alias's replacement text needs to be 'quoted in single quotes' to prevent tabbed -c from being expanded immediately when the alias is defined.


0

On macOS Catalina: echo "alias ll='ls -la'" >> ~/.zshrc Don't forget to close and reopen Terminal after that. As it's explained in article: Apple has changed the default shell to zsh. Therefore you have to rename your configuration files. .bashrc is now .zshrc and .bash_profile is now .zprofile. The difference between .bash_profile and ....


1

If you are using oh my zsh, just activate the dotenv plugin: plugins+=(dotenv) ZSH_DOTENV_FILE=.any-name-you-like-for-the-per-directory-alias-file Also consider direnv, which lets you export environment variables in a per-directory .envrc, and unset them when you move away (which dotenv cannot do). direnv is compatible with all the popular shells. However, ...


-1

If you really want one-liner, then you can use function instead of alias. E.g. you make py3 alias, but it only works in second line: $ alias py3=python3; py3 -c 'print("hello, world")' Command 'py3' not found, did you mean: command 'py' from deb pythonpy command 'hy3' from deb python3-hy command 'pyp' from deb pyp Try: sudo apt install <deb ...


1

I think the bash documentation is unclear here. As noted in another comment, the shell-expand-line documentation implies that all Shell Expansions will be executed, when clearly tilde expansion is not. Additionally, the Quote Removal step does not remove unquoted backslashes still lingering after the first set have been pattern matched, contrary to what 3.5....


2

You should be able to see the issue right there in your question. Look at the syntax highlighting. The problem is that you have a single quote around the alias, but also use a single quote inside it for the sed command. Try this instead: alias repeat "zgrep -i __NCELAB_SNAPSHO \!* | grep -v make | grep -v Flags | sed 's#CODE_COVERAGE_TYPES.*TEST_DONE=1##g'" ...


Top 50 recent answers are included