All Questions
53 questions
-1
votes
1
answer
156
views
Override tr in ~/.bashrc
I'm trying to create a function to translate words via a custom script:
function mean() {
~/scripts/translate.sh $1
}
I would prefer the function to be named tr, as it is much shorter and faster ...
3
votes
1
answer
248
views
How to overload / customize bash (or any other shell) commands handler?
When in bash some non existing command is run, corresponding error message appears:
$ non-existent-command
non-existent-command: command not found
Is it possible to customize this behavior?
I would ...
3
votes
2
answers
358
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 &...
2
votes
0
answers
47
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
...
1
vote
1
answer
315
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 ...
1
vote
2
answers
1k
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. ...
1
vote
2
answers
487
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 &...
3
votes
1
answer
227
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 { ...
1
vote
1
answer
290
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 "...
0
votes
2
answers
468
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 ...
1
vote
2
answers
239
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 (~/....
1
vote
1
answer
765
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 ...
1
vote
1
answer
621
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 ...
26
votes
1
answer
16k
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:
(
...
0
votes
1
answer
100
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 ...