The alias built-in in shells, used to define shortcuts for frequently used commands.

learn more… | top users | synonyms

4
votes
1answer
70 views
+50

Identify alias for the command typed

Is there any shell/shellscript which identifies that there is already an alias for the command I have typed on the command line. Eg On shell I type git checkout master Shell prints "You can use ...
4
votes
1answer
164 views

bashrc lazy substitution

How does one get ~/.bashrc aliases to evaluate $() substitutions at run time, instead of at the time that ~/.bashrc is executed (when opening a terminal)? I run this command often enough that I would ...
1
vote
0answers
16 views

Is there a way to make bash recognize aliases with prefixes [duplicate]

Assume you defined the alias alias grep='grep --color=auto' in ~/.bashrc. Then invoking sudo grep wouldn't trigger the alias to be used. Is there a way to do so? If yes, would that solution be ...
1
vote
3answers
57 views

bash: Saving aliases beyond one session

Recently, I've been fiddling around with Linux's terminal commands to try and get a better feel for the system. I was happy to know that I could give commands a different name in order to call them, ...
0
votes
1answer
23 views

How can I add default command line parameters to an executable in a way that will also work on GUI apps? [duplicate]

I want to pass a command line program by default when I run it. myprog --foo=bar The solution I could think of was to add a custom "myprog" wrapper to my "bin" folder #! /bin/sh /usr/bin/myprog ...
3
votes
2answers
28 views

locally created alias not being used if called using backticks (`)

I have come across this issue while trying to build up a script to do grep on multiple files for 10 different word. The script I created, is (minified) #!bin/bash alias grep='grep -n' out=`grep word ...
2
votes
2answers
70 views

Why am I getting “invalid max count” from grep in an alias?

So the idea is to create an alias that will search my alias's for me. I have quite a few. dude@gnarleybox:~$ grep alg .bash_aliases.sh alias alg='alias | grep ' dude@gnarleybox:~$ alias | grep alg ...
0
votes
1answer
37 views

zsh parse error after alias do=…

I have the following .zshrc file in my home directory: # modify the prompt to contain git branch name if applicable git_prompt_info() { current_branch=$(git current-branch 2> /dev/null) if [[ ...
2
votes
1answer
35 views

How can I use !! in zsh alias

I am trying to create an alias that builds upon my previous command. Say I run ag foo After looking at the list I want to be able to use those results in vim so I do vim -q<(!! --vimgrep) The ...
1
vote
2answers
54 views

Start bash with a specific alias set

I need to start bash in such a way that a specific alias is set. This specific alias would be alias exit="echo Cannot exit" This is important because I am running a program that can only run from ...
0
votes
1answer
26 views

Aliasing a command with parameter supplied to another command

Namely: I want to alias tail -f to less +F but let tail with any other parameter supplied work the same way as before.
2
votes
1answer
106 views

grom() keyword in bash throws unexpected '(' token

I'm not entirely sure why I'm getting the error in my .bash_profile syntax error near unexpected token `(' when I use the keyword grom() for my function. I wanted to create a bash function that ...
2
votes
1answer
240 views

alias -g '${1+“$@”}'='“$@”', what does it do?

Most makefile have this strange set of symbols '${1+"$@"}'. $@ is the makefile target filename. But why does, people try to use the complex symbol like '${1+"$@"}'?
1
vote
1answer
47 views

What is an alias really doing?

I'm looking for a way to check what an alias is really doing, without having to check the ${HOME}/.profile file, or whatever other file where you can define an alias. For example, if I run ll and I ...
0
votes
1answer
124 views

The Alias directive will probably never match because it overlaps an earlier Alias

Here's the original post on Serverfault: The first 15 lines of my httpd.conf file ServerSignature Off ServerTokens Prod ServerRoot "/etc/httpd" Listen *:80 Listen *:443 User apache Group apache ...
1
vote
2answers
50 views

Single or Double quotes when defining an alias?

I know that contents of double quotes are expanded, whereas the contents of single quotes are not, such that echo '$1' gives $1 where as echo "$1" gives <the argument - blank in this ...
1
vote
2answers
57 views

Bash: How to create an alias in .bashrc for awk with parameters

I'm trying to add an alias in .bashrc file as follows: ... alias cutf="_cutf" ... _cutf() { awk 'NR >= $2 && NR <= $3 { print }' < $1 } (The function's goal is to show the ...
3
votes
1answer
73 views

How to swap two commands in bash?

Say I have command A and command B but I want B to run when I type A and vice versa. I've tried alias A='B' alias B='A' But this doesn't seem to work for some reason. How do I do this? EDIT: ...
-1
votes
1answer
51 views

Alias to create and cd into directory [duplicate]

How can I create a reliable alias or function that let me create and cd into one directory? I tried the following, but, as an example can't create directories with spaces. mcd () { mkdir $1 ...
1
vote
1answer
54 views

How to correctly deploy/install scripts?

I've developed several utility scripts that solve specific problems of my team's day-to-day work. Up to now, what I have done to deploy the script in my co-workers' laptops is as follows: Every ...
2
votes
2answers
266 views

How to create permanent aliases on Unix-like systems?

I am looking for a simple way to create a permanent alias for all users. So ~/.bashrc or ~/.bash_profile is not an option. Hasn't anybody created a program for this? I think it should be a very ...
0
votes
2answers
48 views

process substitution for opening a list of files with an application

I wish to use process substitution to direct a list of files (produced, for example, by ls or find) to a particular application for opening/viewing. While piping such a list to xargs is suitable for a ...
0
votes
1answer
37 views

Universal .bashrc alias showing results of sysytemctl start command

This is small .bashrc alias that allows me to see results of starting service alias systemctl start apache='systemctl start apache && echo SUCCESS || echo failure' How can i modify to work ...
8
votes
2answers
457 views

Run another command before running the command the user wants to run

Let's say I want to modify the original behavior of the ls tool this way: $ ls Hello World file1 file2 ... How can I do this? When running ls I would like to run another command let's say echo ...
0
votes
0answers
62 views

Create an alias using Command, Option, Control, or Fn key as part of the input

How can we map these keys into part of an alias or custom shortcut within the terminal? Is it the key codes that must be used or is there another way?
3
votes
2answers
82 views

Why alias inside function does not work?

See the code below: a()(alias x=echo\ hi;type x;alias;x);a I have an alias inside a function, I do not want to change the external environment (that is why I am using () instead of {}), even the ...
0
votes
1answer
80 views

make custom commands on android 4.4.2

I want to program and debug in my android phone. To do that I downloaded c4droid and it's gcc plugin. after a lot of tries I understood that gcc is in directory ...
-1
votes
1answer
171 views

How does this bash alias to repeat the last command as sudo work? [duplicate]

I recently came across this ingenious bash alias to repeat the last issued command, but as sudo. This could be done by using sudo !! directly in the terminal after the failed command. The alias I ...
0
votes
0answers
27 views

Broken mkdir command [duplicate]

I made an alias in my .bash_profile file with the same name as mkdir. It looked like this. alias mkdir='function _blah(){ mkdir "$1"; cd "$1" };_blah' After removing it, i notice that mkdir still ...
0
votes
1answer
79 views

how to find file defining an alias

I am having a problem I'm not sure how to get around. Somehwhere on my system, I have an alias defined as such: alias subl=\''/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl'\' I ...
6
votes
4answers
657 views

Command line shortcuts for changing directory

I'm looking for an easy way to navigate to directories spanning multiple hard drives and want to set something equivalent to a shortcut within the terminal. In Windows I would accomplish this with ...
1
vote
1answer
23 views

How do I make an alias to substitute single word in a piped command? [duplicate]

I use aliases a lot but right now only for use cases like alias i='sudo apt-get install -y'. I often would like to add an alias in the following form: alias cmd='echo [something] >> ...
1
vote
1answer
91 views

Alias for perl script

So far while surfing web I've discovered nice addition to my gpg password generator and I've decided to adjust my alias with these commands. Here is the code gpg --gen-random 1 20 | perl -ne'print ...
0
votes
0answers
47 views

Setting different path for installation in python packaging

I am new to python packaging. My Command Line Interface (CLI) named virtdc modules has to be installed in /var/lib/virtdc. virtdc is the top folder structure /var/lib/virtdc/ framework/ ...
0
votes
1answer
51 views

ksh your own shortcuts, aliases, settings each login?

I need to set up some handy dandy keyboard shortcuts as I am fed up with setting up various aliases each login time from scratch. what is the most convenient way to do this since I don't have the ...
2
votes
1answer
114 views

calling Bash Function from alias definition

I am using Xilinx ISE, a program that requires to source a vendor script to setup the path for all its tools. Since this script breaks some functionalities of my shell I do not want to source it on ...
2
votes
2answers
122 views

How to create an alias to the directories and copy one file to another?

I want to copy a file from /home/e_empid/file1 to /home/e_empid /dir1/dir2/dir3/Backupfile1. User does not want to write a long command each time. Write a command to set an alias for above action? I ...
2
votes
2answers
291 views

How to create an alias for a sequence of commands? [duplicate]

I know it for one command but how to work with a sequence?
7
votes
3answers
491 views

in Bash, how to not include extra arguments in an alias?

I am trying to do something like alias ftp='echo do not use ftp. Use sftp instead.' just so that ftp will not be accidentally used. But I noticed that ftp abcd.com will cause the command to ...
3
votes
0answers
68 views

parametric aliases in csh to add export command

I'm trying to find a way to translate functions to csh/tcsh aliases, since they lack functions but have parametric aliases. As a first step I'm trying to create an export command. Here's what I've ...
0
votes
1answer
68 views

How can I write an alias for cd such that it will fire ls after going into the directory to which I just cd'ed into? [duplicate]

Lets say I want to do cd home and then ls -lrth. I want these two things combined into a single command. I tried writing an alias, but it didnt work. Can you help me ?
0
votes
1answer
30 views

tcsh alias for cd through path of a port after searching

Now I try to create an alias for this command: alias cdport 'cd `whereis \!^ | awk \'{print $2}\'`' Can't find any good examples of using more than 2 commands in a sequence. How to fix that ...
1
vote
1answer
62 views

How do I define alias with variables which can be changed at runtime?

This is probably a very easy to answer question, but I could not find any questions already asking this due to different wording when writing titles. Running help alias on my bash prompt returns only ...
0
votes
1answer
55 views

Trying to make aliases that open the last modified file

One thing that I frequently do is edit the most recently modified files, so instead of typing "ls -lr" and then "vim lastfile", I thought I would make some shortcuts in my ~/.bash_profile file: alias ...
4
votes
5answers
403 views

how to use regex in alias?

I want to create the alias for the command "ssh user@10.32.44.225" as 10.32.44.225 alias [0-9][0-9][0-9].[0-9][0-9][0-9].[0-9][0-9][0-9].[0-9][0-9][0-9]="ssh user@$0" I have created it, but it is ...
2
votes
1answer
73 views

why completion does not work for all aliases?

In my .bash_aliases file I have couple of aliases, like -- shopt -s expand_aliases alias emx='emacs' alias em='emacs -nw' alias gv='gvim' alias v='vi' alias ev='evince' when I use them and press ...
3
votes
1answer
68 views

Run command with sudo by default

Just one brick missing in my current wall. Feels to me like it should be easy to solve, nevertheless I got some explaining for you to do to make you understand what I want to achieve. I need a linux ...
2
votes
2answers
98 views

An alias for a command to kill stopped jobs

I wanted to add an alias to my .bashrc so that I could kill all stopped jobs with a command like kill_stopped. I am aware that kill `jobs -p` can be used to accomplish this but I'd rather have an ...
2
votes
2answers
110 views

Clear or disable aliases in zsh

I installed oh-my-zsh to make terminal use a bit easier. One thing that bugs me though is the prolific aliases added by it, like "ga", "gap", "gcmsg", "_", which are harder to remember than the ...
5
votes
1answer
98 views

How can I create an alias that passes additional arguments?

I have an executable that I use often: /dir1/dir2/dir3/dir4/executable argv[1] argv[2] argv[3] I know that I can set an alias for the executable: alias myexecutable = ...