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.
745
questions
1
vote
1answer
27 views
How can I get my csh alias to work in bash?
This alias works fine in /bin/csh but not in /bin/bash:
alias cd='chdir !* && setprompt; clear; ls -F'
Basically, I would like to cd to any directory and ls in color.
0
votes
0answers
17 views
Defining zsh aliases and functions systemwide
What's the most efficient way to export the functions/aliases defined in my .zshrc to be used anywhere. For example in my .zshrc
_foo() {
echo "bar"
}
And then invoke _foo in any script.
0
votes
1answer
21 views
Variable in Bash Alias not working as intended [duplicate]
The alias doesn't work properly until running source ~/.bashrc or source ~/.bash_aliases ONLY AFTER running the alias once first. Is there a magical way to get the $todaydir string to be replaced ...
0
votes
4answers
53 views
Writing custom alias for common bash commands
[best practices question]
I'm just getting started with unix - and I find some of the common operations e.g. creating symbolic links ln -s or renaming files mv unintuitive.
I am debating whether to ...
0
votes
0answers
21 views
Conditional Git alias within zsh: “parse error: condition expected: cd” [duplicate]
I'm trying to implement a simple stack of git-related aliases for my personal dotfiles.
alias gs="[[ $(git rev-parse --is-inside-work-tree &> /dev/null) ]] || cd $D && git status -...
32
votes
6answers
2k views
Are there any single character bash aliases to be avoided?
Often I find my self making single character aliases, because after all, they exist to save input time. I'm curious if this should be avoided. I do not know of any conflicts.
0
votes
0answers
39 views
Why is the wrong version of Python launching?
Take a look. When I type python3 I want python3.6 to launch. Instead I am getting 3.5.2. There's something wrong with my path or alias or something else, but I can't spot it. I would love another set ...
0
votes
1answer
21 views
How to make `at` command to understand the bash alias or function?
I am having a function written inside bashrc like -
function build_image ()
{
...
}
This function will trigger compilation of the source code.
Now I need to trigger this image building/compilation ...
0
votes
2answers
54 views
zsh: When running source I get zshrc:116: unmatched
So today I wanted to add some extra alias to zsh.
I did the usual
nano ~/.zshrc
and added my alias
ex:
alias desktop="cd desktop"
(I've doubled checked that all variables for typos)
Ctrl+...
0
votes
1answer
45 views
Do zsh aliases lower terminal performance?
I really make use of aliases and I've started to create some function aliases which are made of only one if..else case. For instance, I have the following alias to start my json-server:
jsp() { ...
0
votes
2answers
47 views
Is it a good practice to use aliases? [closed]
I have a colleague who likes to use aliases instead of writing scripts, but I don't want to do this.
First, you need to set the same alias on each computer. They behave differently on different ...
0
votes
0answers
25 views
Alias a command with the Incoming Prompt Options
I have an alias in my .zshrc which connects me to my VPN.
The alias is like this:
alias vvv="sudo openconnect xx.xx.xxx.xx"
After running this command, I will be asked a yes/no question, ...
0
votes
1answer
19 views
Setting an alias for copying the current path from shell to clipboard fails [duplicate]
I have added the following alias to my .zshrc:
alias pwdc="echo -n $PWD | xclip -selection clipboard"
it seems the present working directory is not getting updated, when I move to a ...
1
vote
2answers
71 views
Make alias from existing alias
I have 2 separate files, which are both sourced from my .zshrc, one of them (the first one) is defining this alias:
alias wget='wget --hsts-file="$XDG_CACHE_HOME/wget-hsts"'
problem is that ...
0
votes
1answer
25 views
while read loop not working inside alias [duplicate]
In Bash, the following command
echo foo | while read line; do echo $line; done
outputs foo; however, the following
alias bar="echo foo | while read line; do echo $line; done"
bar
outputs a ...
0
votes
0answers
19 views
Can I use Alias to redirect / link to another subdomain folder?
I have a VPS with an ISP Manager panel.
With domains
domain1.com
domain2.com
domain3.com
And subdomains
cart.domain1.com
cart.domain2.com
I need to display cart.domain2.com when opening cart....
1
vote
1answer
31 views
gcloud setting up zsh alias
I was trying to set up some alias command and function for gcloud.
I have written below function and running it in zsh in mac.
It runs fine when I pass c and i as individual arguments but not when I ...
0
votes
0answers
32 views
how does bash alias expansion work? [duplicate]
I have the following lines in my .bash_aliases file
alias enw='emacsclient -nw'
alias gie='enw ~/.config/git/ignore'
alias ls='ls --color=auto'
and I don't understand how and why they all work (they ...
1
vote
1answer
28 views
How to set an environmental variable from another script?
I set a variable WORKSPACE="$(git rev-parse --show-toplevel)" in ~/.bashrc - which essentially sets $WORKSPACE to the root of the git repository
so that I can write alias for some of the ...
-1
votes
1answer
40 views
How to make .bashrc alias that runs an .sh file containing a second alias, and then runs that second alias?
Is it possible for me to do what is described in the title?
Lets say I have a script "initstuff.sh" and within that script there is an alias "shalias" that runs some stuff. Putting ...
1
vote
2answers
109 views
alias using `$1` and fallback default value prints both the param and the fallback value
I want to create an alias that can handle parameters ($1),
and can fall back to a default value if a parameter is not provided.Ā
ForĀ example,
$ alias foo='NUM=${1:-42}; echo $NUM'
Invoked without ...
0
votes
1answer
303 views
Bashrc file error when running kali linux terminal
I get this every time I run terminal on kali linux. It started happening when i added the alias "wifi". This is the error i get
bash: source: filename argument required
source: usage: source ...
0
votes
2answers
60 views
Using an alias of command that includes awk
alias ip="ifconfig eth0 | grep '255$' | awk '{print '\$2'}'"
Using the command alias with no argument I then get
alias ip='ifconfig eth0 | grep '\' '255$'\'' | awk '\''{print '\''$2'\''}'\''...
1
vote
1answer
55 views
Alias grep “$1” filename doesn't work, somehow “$1” went missing
Normal grep
wolf@linux:~$ egrep 4.4.4.4 data.csv
A,4.4.4.4,4.4.4.5,4.4.4.6,3.3.3.3,3.3.3.4
wolf@linux:~$
Since I've a lot of data to grep, I've put it on alias.
wolf@linux:~$ alias z="egrep $1 ...
0
votes
1answer
72 views
How to modify a bash alias to take input from the terminal?
In my .bashrc, I have aliases:
#Custom aliases
alias gta="git add -A"
alias gtc="git commit -m 'Added files' "
I want to create a new alias that does the command git push origin &...
3
votes
1answer
139 views
How to use aliases with `watch` command?
I have some bash aliases in my ~/.bashrc, but they're not available within a watch command. Normally, I would source ./some_script.sh which uses these aliases, but am having trouble figuring out how ...
1
vote
0answers
33 views
Best location for system-wide bash aliases to be managed by CM tools?
I understand that, normally, system-wide aliases (which affect all users) belong in /etc/bash.bashrc (at least on Arch Linux and other common distros I'm familiar with).
However, for automatically ...
2
votes
1answer
146 views
Using colon for aliase breaks autocomplete
I'm using colon or other prefix for aliases in .bashrc.
For a while I was using short keys like:
alias :t="tmux"
alias :www="google-chrome --use-gl=desktop &>/dev/null &"...
1
vote
2answers
65 views
How to make bash alias work with command inclusion i.e. $() (the dollar sign and parenthesis)
I used to have aliases like:
alias mount-open="sudo mount $(sudo blkid | gawk '/2tb-open/ { print substr($1, 0, 9) }') 2tb-open"
I can't be 100% sure that it was the same, but 100% it was a ...
2
votes
2answers
664 views
How to make `python` an alias of `python3` systemwide on Debian
The latest updates of my Debian testing system removed Python version 2, and I only have Python 3 installed, with python3. There is no longer any command named python. This causes several scripts to ...
1
vote
1answer
96 views
How can I make this git alias with quotes work?
I want to make a git diff alias that only shows the changed lines (coloured).
[alias]
mdiff = diff --color | grep --color=never $'^\e\[3[12]m'
This doesn't work, as apparently pipes cannot be ...
1
vote
2answers
45 views
Aliasing grep in find's -exec option
I have these aliases in my ~/.bashrc
alias grep='grep --color=auto -H'
alias fgrep='fgrep --color=auto -H'
alias egrep='egrep --color=auto -H'
but they have no effect when I run find ... -exec grep .....
0
votes
1answer
31 views
Scaping single quota in zsh alias
I like create any alias for docker commandas, and I need any alias use single quotes.
I see post Escaping quotes in zsh alias but not work for me.
Tried in .zshrc
function dinfoip() {
docker ...
1
vote
1answer
58 views
xdg-open autocomplete not working when calling it with alias
I've set an alias to xdg-open adding alias op="xdg-open" to my ~/.bashrc file.
The command op file.pdf works, but I'm not able to autocomplete when typing, for example, op fi and hitting TAB....
0
votes
1answer
27 views
Linux - User Display name alias in shell prompt
Is it possible to alias the user display name in the shell prompt?
For example: When I ssh with john123@192.168.1.2, it displays as John123
[John123@myhost ~]#
Can I change it to a alias csgeek ...
0
votes
0answers
12 views
How can I enforce HTTP basic authentication on an Apache directory that is an alias?
I'm using Ubuntu 18.04 with Apache 2.4. I have created this htpasswd file ...
$ ls -al /etc/apache2/.htpasswd
-rwxr-xr-x 1 www-data root 49 Aug 20 20:57 /etc/apache2/.htpasswd
I have this in my /etc/...
0
votes
1answer
20 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 ...
2
votes
2answers
88 views
Where are default aliases defined
I've got a fresh install of CentOS 8 (minimal ISO). I notice that, despite none being listed in either .bashrc or .bash_profile, a bunch of aliases are defined by default in bash. For example,
alias ...
1
vote
1answer
127 views
When should you make a symbolic link instead of making an alias?
It's possible that making a symbolic link is not at all comparable to making an alias. But from what I understand about symbolic links so far, they do the same thing as setting an alias: they define a ...
1
vote
1answer
29 views
Nested settings in ssh config for domains and aliased subdomains
How can I have rules for a whole domain and also create aliases with rules for each of the subdomains without duplicating all the ruleset?
In other words, why is it that in the following example ...
0
votes
1answer
39 views
How do I source a new .bashrc in an alias that switches my shell?
I have an alias I use to run sudo -s called ssu. I want it to also source my root session from the .profile in my home directory.
Other answers seem to say that this is the solution:
alias ssu='sudo -...
0
votes
2answers
57 views
Why are aliases skipped if escaped?
A common way to skip aliases is to add a backslash before the aliased command.
For example,
$ alias ls='ls -l'
$ ls file
-rw-r--r-- 1 user user 70 Jul 30 14:37 file
$ \ls file
file
My research has ...
0
votes
2answers
32 views
Running a script when a particular command is run
I want to run "./dothis.sh" if someone executes "cat abc.txt"
Is there some way to do this without using alias?
I want to use this for strengthening security of some specific files ...
2
votes
2answers
126 views
Execute zsh alias when name contains a hyphen
A stock-standard zsh behaves as follows with an alias with a - in it, eg: a-a:
% zsh -f
svelte% alias a-a=date
svelte% a-a
Sun 19 Jul 2020 17:20:05 +07
My configuration has it behave as follows:
% ...
0
votes
1answer
42 views
Can we make aliases for the commands with parameters
I want to make alias for:
rm -rf * => #rm -rf *
rm * => #rm *
When I type rm -rf *, I want it to be commented out and not take action.
[Q] General question is can we make generate aliases for ...
2
votes
1answer
152 views
Unsure if alias to combine apt-get update and apt-get upgrade is working correctly
Here are the aliases in question:
alias update='sudo apt-get update'
alias upgrade='sudo apt-get upgrade'
alias upgrate='sudo apt-get update && sudo apt-get upgrade'
Here's the output when I ...
0
votes
1answer
32 views
How to find where ksh setup aliases?
Where ksh can load aliases from?
Checked /etc/profile, ~/.profile - nothing
There is no ~/.kshrc.
Tried:
$ grep -r 'alias BADALIAS' /etc - also nothing
1
vote
1answer
42 views
Which binary would be run when we have multiple installations?
I wanted to set gsettings as /usr/bin/gsettings so I created an alias. But I am not sure if that works:
$ type gsettings
gsettings is aliased to `/usr/bin/gsettings'
gsettings is /home/linuxbrew/....
1
vote
4answers
127 views
bash alias to create folder and move file
I am trying to create a bash alias to do the following:
create a folder (with the current date as the folder name)
move (or copy, either is fine with me) a file from the current folder into the new ...
0
votes
1answer
29 views
Idiomatic setting of nicknames/aliases?
On Unix systems, you have your username, say "johnsmith", and your full name, "John Smith". That's it.
Now, suppose I want to use a nickname or two - something which isn't my ...