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

learn more… | top users | synonyms

4
votes
3answers
99 views

-bash: unalias: ls: not found

I am trying to install tomcat 8 on centos 7. I am using the terminal as root. When I type in source ~/.bashrc, the terminal gives back the following error: -bash: unalias: ls: not found. How can ...
1
vote
0answers
20 views

GNOME 3.14+ launch new gnome-terminal and set title

To the disappointment of many, tab/window title can't be set anymore with --title I use bash. I have had a few aliases I have used to connect to remote servers with. alias c:prod='gnome-terminal ...
4
votes
1answer
32 views

Aliases fail to persist after sourcing script

Here is my script: echo "Defining aliases" echo $$ echo " s=screen v=vlock -a j=jobs " | sed '/^$/d' | while read alias do echo $$ alias "$alias" alias | wc -l done And here is its output: ...
-1
votes
1answer
37 views

Prevent use of alias in script [closed]

I have a grep alias on my .bash_profile that display line numbers and color the matches. This is an example of my grep results: $ grep test filename 1:This is a test (to be removed) 1:This is a ...
1
vote
3answers
59 views

Use alias after issuing sudo su command

I am on AIX 7.1. I have a bunch of aliases defined in my personal .profile. alias df='df -k' alias cl=clear alias h=history alias ll='ls -al' alias lt='ls -latr' alias ls='ls -Fa' alias psj='ps -ef ...
1
vote
1answer
34 views

Aliasing a command with special parameters [duplicate]

I would like to have an alias for the following code:- g++ *.cc -o * `pkg-config gtkmm-3.0 --cflags --libs`; but I want that when I enter the alias it should be followed by the file name *.cc and ...
0
votes
1answer
22 views

Returning last-written file, containing particular sub-string in file name?

Whilst monitoring logging I have to go to my log files, order by written date, so I can then see the name of the log file for the most-recent execution of my application. Is there any way, given a ...
1
vote
0answers
25 views

Is it possible to create aliases that affect services starting?

Currently I have a custom service that executes java in multiple places. I want to be able to add an option to any executions of java this service will spawn (I'm specifying the error log location, ...
-2
votes
3answers
44 views

Can an argument be passed through the “alias” command? [duplicate]

I want to know if i can pass an argument with an alias command. for example: alias d="dmesg|grep -iw usb|tail -5" Now d will print the last 5 lines. if i want to use d to print a different number ...
1
vote
2answers
92 views

bash - Why does type -a execute “$(printf 'a')” and is it possible to get back the original alias? [duplicate]

After i ask this question 2 days ago, i decided to make this alias in my ~/.bashrc: alias catvu="LC_ALL=C sed \"$(printf 's/[^\t -\176\200-\377]/^&/g')\"|LC_ALL=C tr '\0-\10\13-\37\177' ...
0
votes
1answer
30 views

zsh alias with linefeeds, commas and quotes

In my zshrc I have an alias like this: alias sl='screen -list' It fits my need (seeing what screens I have running), but the output is rather ugly: [pts/7]~% sl There are screens on: ...
6
votes
2answers
133 views

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
184 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
73 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
30 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
32 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
207 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
111 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
48 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
60 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
29 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
146 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
256 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
49 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
545 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
85 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
74 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
83 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
69 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
73 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
435 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
66 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
48 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
464 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
68 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
112 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
105 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
281 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
169 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
1k 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
25 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
107 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
68 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
77 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
201 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
155 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
320 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
500 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 ...