Questions tagged [alias]
An alias is essentially nothing more than a keyboard shortcut, an abbreviation, a means of avoiding typing a long command sequence. This can save a great deal of typing at the command-line and avoid having to remember complex combinations of commands and options.
926 questions
0
votes
1
answer
93
views
How to wrap source command in tcsh
I need a solution only for tcsh.
Say I have a source file that sources other files which in their turn can source other files. My goal is to track which files were eventually sourced. One way I can do ...
1
vote
2
answers
108
views
How can I temporarily bypass an alias of a keyword in Bash?
If I alias a keyword, I can't figure out how to bypass it.
$ alias if='echo "GOTCHA!"; if'
$ if true; then echo y; fi
GOTCHA!
y
The usual tools for bypassing an alias, like escaping, ...
-1
votes
2
answers
166
views
Unable to Execute Multiple Alias Commands Simultaneously
I'm encountering an issue where I'm unable to execute multiple alias commands at the same time in my shell environment. For example, when I try to run two alias commands together, only one seems to ...
0
votes
1
answer
70
views
Alias for rm does not include file name with @$ [duplicate]
I am trying to create an alias for the rm command in the /root/.bashrc file on a VirtualBox Redhat VM (running RHEL 9). I cannot get it to work properly. This is an excerpt of my .bashrc file:
alias ...
0
votes
2
answers
155
views
In a bash alias, how do I run "apt autoremove" automatically after "apt upgrade" only if needed?
I have two alias in my Debian's .bashrc:
alias upd='sudo apt update && apt list --upgradable'
alias upg='sudo apt upgrade'
Then I use upd to update and display all upgradable packages, and ...
0
votes
2
answers
150
views
How to expand a Bash alias given as an argument?
I probably approach this problem wrong. I update my Linux machines with bash aliases like:
alias upg-pi='\ssh -c [email protected] -C -i $ssh_identity -o ConnectTimeout=$ssh_timeout root@$...
-1
votes
1
answer
90
views
zsh alias causes error if used in fish
I have the following aliases in my zsh:
alias -- -='cd -'
alias ..='cd ..'
alias ...='cd ../..'
When I switch to fish, by manually typing fish and pressing Return, the first alias causes an error:
- (...
0
votes
1
answer
126
views
Inheriting path modifications vs. Inheriting aliases
My login shell is zsh. I have added the following two lines to my .zprofile file:
path+=$HOME/foobar123
alias foo='echo bar'
Then, if I switch to bash or fish, by typing bash or fish and pressing ...
0
votes
1
answer
69
views
zsh, .bash_profile, and aliases
I have a script downloaded from the Internet, the beginning of which looks like this:
echo "alias myip='curl -s https://api.ipify.org/'" >> ~/.bash_profile
echo "alias myiplookup='...
0
votes
2
answers
130
views
Bash - get file count
I have the following alias defined in my .bashrc
alias lsfc='ls -l "$@" | tee /dev/tty | grep -v / | echo "File count: `wc -l`"'
which is intended to give me the number of ...
-1
votes
1
answer
185
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 ...
0
votes
1
answer
124
views
Get a list of all user's commands from a non-interactive shell
I am writing a script that would automatically suggest some new aliases/functions to be added to a user's shell config. Before doing that, however, I would like to make sure the aliases being ...
1
vote
2
answers
248
views
How to write an alias or bash script that renames a single file using the same syntax as the `ren` command of Windows?
I am a long-term a Windows user, so I find the syntax of the ren command both simple and convenient:
ren C:\pathTo\myFile\oldFileName.txt newFileName.txt
[Update 24 July 2024] To be clear about my ...
3
votes
2
answers
399
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
48
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
...
0
votes
2
answers
154
views
Is it possible to use a command with an argument to trigger a bash alias?
I have a program that tries to trigger a screenlock using the following commands:
xdg-screensaver lock
xscreensaver -lock
cinnamon-screensaver-command --lock
The problem is that I'm using ...
0
votes
1
answer
96
views
Is there a way I can use .bash_aliases in a shell-scripts? [duplicate]
Is there a way I can use bash aliases from my .bash_aliases file within a shell-scripts?
I thought of something like including
source "$HOME/.bash_aliases into my script
but it does not work.
0
votes
1
answer
248
views
Can I reprogram the pwd command to add a trailing slash?
WHen I use the pwd command, it prints e.g /opt instead of /opt/. I would like it to print the trailing slash. However, I tried adding the following line to my ~/.bash_aliases file:
alias pwd=" ...
1
vote
1
answer
301
views
How can I remove aliases "which-command=whence" and "run-help=man"?
I'm running Artix Linux and using zsh, and these two aliases return no matter how many times I unalias them or remove them from my aliasrc:
run-help=man
which-command=whence
And they don't exist in ...
0
votes
1
answer
116
views
ksh88 string substitution in alias | mpv streaming [duplicate]
tl;dr how can I substitute a string (i.e. a youtube/streaming url) in an alias such as alias mpvyt='yt-dlp <URL> -o - | mpv - ' ?
I live in a mezzanine studio using a M1 macbook for a ...
2
votes
1
answer
266
views
Converting a tcsh alias into zsh
I had a tcsh alias as follows:
alias cdd 'cd `dirname \!*`'
I use this to change the directory to the one containing a certain file.
For instance,
cdd /Users/myself/Document/Folder/File.pdf
would ...
1
vote
3
answers
1k
views
How to config alias on RedHat server?
I'm using a server where I'm a common user (non-sudo).
I access the server through ssh.
Here's the output of some commands run on the server:
[username@machinename: ~]$ ps -p $$
PID TTY ...
1
vote
1
answer
611
views
Unix Command (and bash alias) or script to band/unban IP addresses in Fail2ban without having to lookup and specify "jail name"
I am creating a bash alias (or possibly a script) to ban and unban IP addresses with fail2ban on Ubuntu 20.04.
The bash syntax I am using to unban IP address is:
fail2ban-client set YOURJAILNAMEHERE ...
0
votes
0
answers
99
views
Bash script ignores all terminal input following an underscore [duplicate]
Goal
My server manages jobs using SLURM. Each job in the queue has a job ID, which can be either a single integer or two integers separated by an underscore, e.g., 123_4. You can use scontrol show job ...
0
votes
1
answer
383
views
How to use alias command with a paramiko SSHClient connection?
I am trying to execute the following, with no success getting either the 'py3start' or the 'py3test' alias commands recognized - (I introduced the 'py3test' for testing purposes to check if setting ...