Replacing an alias in Fish Shell

Question: Is there a Fish equivalent for replacing the Bash alias, or a recommended recommendation for saving code and DRY?

Background: . Here, a very useful alias function in Bash is called alias substitution. He briefly mentioned on the man page:

alias [-p] [name[=value] ...]
    ...
    A trailing space in value causes the next word to be checked for alias substitution when the alias is expanded.
    ...

The strength of this functionality can be easily conveyed with an example. Note that many users define the grep alias. Here's mine:

# extended regex, skip binaries, devices, sockets, & dirs, colored, & line
# -buffered. use a non- canonical alias instead of GREP_OPTIONS which may wreck
# poorly written scripts
alias g='grep -EID skip -d skip --color=auto --line-buffered'

Similarly, many of the same users define an alias for xargs. Here's mine without replacing aliases:

alias x='xargs -rd\\n' # \n delimited, don't run on empty in

And finally, here is how I can use it, but it does not work:

$ find|x g foo
xargs: g: No such file or directory

, x xargs g. , , . , , , :

alias x='xargs -rd\\n ' # \n delimited, don't run on empty in, + expansion
#                    ^-- this space is for expanding a subsequent alias

, , , .

2015-05-06

Fishism, , . ~/bin. :

  • .
  • .

, , :

  • .
  • . . script, .
+4
1

, , .

.fish .sh /usr/local/bin - .

+2

Source: https://habr.com/ru/post/1584097/


All Articles