Skip to main content

All Questions

Tagged with
3 votes
2 answers
287 views

how to alias the `history` function in fish shell

I'm trying to set the fish history pager to be bat -l fish for syntax highlighting. (i.e. set the PAGER environment variable bat -l fish just for the history command). I tried: # 1: alias history &...
matan h's user avatar
  • 147
2 votes
0 answers
45 views

Can't unalias then redefine as a function in the same conditional [duplicate]

Here is a simplified implementation of an issue in my bash/zsh aliases file: alias foobar='echo bar' # this is out of my control if true; then unalias foobar echo we got inside the conditional ...
Adam Katz's user avatar
  • 4,012
1 vote
1 answer
266 views

How to write a function that takes an argument string that does not need to be quoted?

I'm writing a function, adding it to ~/.zshrc on my Mac. It's in order to more quickly handle commands to youtube-dl. I have this: function dlv() { cd /Users/admin/Downloads youtube-dl ...
Alfie Stoppani's user avatar
1 vote
2 answers
900 views

How can I/Should I default flags when running a command?

For context, I'm using zsh. Every time I use locate, I want to pass the -i and -A flags. Usually, if I can get away with it, I create an alias with the same name as the existing command to do this. ...
Daniel Kaplan's user avatar
1 vote
2 answers
388 views

zsh: alias or shell function to only echo its command line, including shell control characters

Using zsh, I'd like to create an alias or a shell function that operates as follows: I want this alias or shell function to echo its command line without honoring any shell control characters such as &...
HippoMan's user avatar
  • 647
3 votes
1 answer
213 views

Making simple backup alias / function?

OK, so all I really want to do is backup single files as a time in the current directory with '.bak' extension. Here is my current function that does this (jsyk, using Rocky Linux): function backup { ...
GregTheHun's user avatar
1 vote
1 answer
273 views

How to call many shell functions from sudo?

I have a huge alias file sourced by ~/.bashrc or ~/.zshrc which contains both simple aliases and more functions for more complex stuff: # example aliases alias "sudo=sudo " alias "...
Polizi8's user avatar
  • 285
0 votes
2 answers
397 views

Finding duplicate aliases and functions in a script (.bashrc etc)

This site says that functions are faster than aliases, but he rightly points out that aliases are easier to understand - when you want something very simple and do not need to consider passing ...
YorSubs's user avatar
  • 641
1 vote
2 answers
204 views

bash, pass an argument to the 'history' command

I do the following to make history more sensible (i.e. seeing when a command is run can be fairly critical when troubleshooting) shopt -s histappend; # Append commands to the bash history (~/....
YorSubs's user avatar
  • 641
0 votes
1 answer
635 views

How to evaluate bash alias before being passed to bash function?

I have defined a test alias as: alias testalias='python3 -c "f = open(\"/tmp/testopenfile\", \"w+\"); f.write(\"hi\n\")"' It works fine when I run it directly ...
Machinexa's user avatar
  • 123
1 vote
1 answer
550 views

bash, "\" in an alias or function

I use Windows and Linux a lot, and sometimes I type cd\ from Windows muscle-memory, so I tried to alias that, alias cd\='cd /' but that doesn't work (presumably because \ is an the escape character in ...
YorSubs's user avatar
  • 641
25 votes
1 answer
14k views

How to make a multiline alias in Bash?

I want to make an alias for a multiline ​command to call it faster then copying-pasting-executing it from a text file each time. An example for such command is this execute-a-remote-updater command: ( ...
timesharer's user avatar
0 votes
1 answer
83 views

bash function to replace every occurence of text in directory and subdirectories

I found (on Google) this perfectly working line to replace every occurences in all files in my directory and subdirectories: grep -lr previoustext | xargs sed -i 's/previoustext/newtext/g' It works ...
Zkyem's user avatar
  • 3
0 votes
0 answers
18 views

Alias or Function for a Command [duplicate]

Sometimes (or may be all the time) an Alias and Function for a command works the same way. For example, following Alias and Function of Ping Command: alias Pingoogle='ping -c 3 google.com && ...
Salman Ahmed's user avatar
0 votes
1 answer
97 views

$@ in alias inside script: is there a "local" $@?

I have aliased pushd in my bash shell as follows so that it suppresses output: alias pushd='pushd "$@" > /dev/null' This works fine most of the time, but I'm running into trouble now using it ...
Théophile's user avatar

15 30 50 per page