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

learn more… | top users | synonyms

2
votes
1answer
286 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+"$@"}'?
2
votes
2answers
51 views

Alias doesn't seem to read from STDIN

I'm looking for an alias to convert hex from hexdump output into "Python's" hex notation: $ echo "5f 74 34 0c c9 7b 9f f8 7a 7c 46 ff ff 5c 31 26" | sed 's/ */\\x/g' | awk '{print "\\x"$0}' ...
10
votes
3answers
234 views

Defining an alias and immediately use it

In zsh this works fine: alias foo=ls foo But this does not: alias foo=ls; foo Pressing enter an extra time is not an issue when running interactively. But when running through ssh it suddenly ...
2
votes
1answer
87 views

Why root bash output is colored but `sudo ls` output is not?

In bash (Ubuntu) I get colored outputs either as root (after sudo su) or as a normal user. I checked (after reading this post) the files .bashrc for normal user and superuser and the options related ...
3
votes
1answer
28 views

How do you make an alias or function that retains tab completion?

I made an alias to save some keystrokes with working with systemd: $ alias sctl='systemctl' However, this breaks tab completion for the subcommands. Is it possible to alias a command without ...
2
votes
1answer
22 views

csh: Convert aliases into commands that set these

The command alias lists the active aliases. But it does this in a way that is different from how to set the alias: % alias foo 'bar \!*' % alias baz quux xyzzy % alias corge 'grault \ garply (quux ...
122
votes
17answers
58k views

How to have tail -f show colored output

I'd like to be able to tail the output of a server log file that has messages like: INFO SEVERE etc, and if it's SEVERE, show the line in red; if it's INFO, in green. What kind of alias can I ...
10
votes
2answers
10k views

How to reset a shell environment?

This issue has been bugging me for a while, and although I've thought I've found my answer through EnvWatcher, unfortunately it only works on Bash. And I use zsh. I would like to replicate the things ...
0
votes
2answers
2k views

Why doesn't alias work in AIX (Korn shell, .profile)?

I have these files in my home directory: drwxr-xr-x 3 meuser staff 256 Oct 12 13:11 . drwxr-xr-x 102 bin bin 4096 Sep 30 12:28 .. -rw------- 1 meuser staff ...
2
votes
3answers
56 views

How to make an alias permanent?

I have created an alias: alias shh='sqlplus hfdora/hfdora@hfd1" After creating this alias I was able to enter my database only by typing shh. But after closing my shell, I wasn't able to find ...
7
votes
2answers
4k views

cp -f cannot overwrite cp -i alias

In my /home/user/.bashrc file, I have those aliases to prevent mistakes: alias rm='rm -i' alias cp='cp -i' alias mv='mv -i' If I'm really sure of what I'm doing, I can overwrite rm and mv aliases ...
3
votes
2answers
76 views

How to alias part of expression for find?

I prefer regular expressions with -regex over the shell pattern syntax of -name. I also want to use the posix-egrep type, so I'd like to do something like alias find="find -regextype posix-egrep" ...
4
votes
2answers
783 views

Creating an alias to Change Directory and have that directory be the current working directory in new terminal tabs

I'm trying to create a convenience alias that will change directories and then start a node server in that directory. I have it working for the most part, there's just one little issue that I can't ...
2
votes
2answers
29 views

Using xfreerdp with variable IP/hostname [duplicate]

I got a very simple alias on my bash: alias xfreerdpp='xfreerdp /v:ip_address /u:username /d:domain /p:password /size:1024x768 /clipboard /cert-ignore &' All I want to do is to make the ...
0
votes
1answer
1k views

SUSE Linux 12 - configuring IP alias

I want to setup an IP address alias on a network card. I created a file /etc/sysconfig/network/ifcfg-ens160 and its contents are: BOOTPROTO='static' STARTMODE='onboot' IPADDR='192.168.0.113' ...
1
vote
1answer
62 views

How do I nest quotes four deep?

I have a complex command that I'm running in watch to nag users to get out of a filesystem when I need to unmount it. The following is working watch -ben5 $'lsof /mnt/unfs && ps --no-headers ...
1
vote
1answer
48 views

Get executable for any command [duplicate]

I want to know which executable gets executed for any command in bash. Example: I have firefox installed here /usr/bin/firefox, it is in the $PATH alias browser=firefox alias br=browser Now I ...
45
votes
4answers
7k views

How to use `which` on an aliased command?

Like most users, I have a bunch of aliases set up to give a default set of flags for frequently used programs. For instance, alias vim='vim -X' alias grep='grep -E' alias ls='ls -G' The problem is ...
20
votes
5answers
6k views

How can I create an alias for a git [action] command (which includes spaces)?

Most of my my aliases are of this form: alias p='pwd' I want to alias git commit so that it does git commit -v But trying to create an alias with a space gives an error: $ alias 'git commit'='git ...
-1
votes
1answer
56 views

How to rename or delete an alias permanently from system?

I have created one alias in my system, printf "%s\n" "alias shh='sqlplus hfdora/hfdora@hfd2" >> ~/.kshrc Now, I want to change the alias name from shh2 to shh Also, how to delete other ...
2
votes
2answers
145 views

How to generate a random string in a profile alias?

I have an alias in my server's /etc/profile which generates a random directory on command, like this: alias rdir="mkdir -p ./`cat /dev/random | tr -cd 'a-z0-9' | head -c 8`/" But it turns out this ...
2
votes
2answers
1k views

Non-interactive shell expand alias

I'm having trouble getting aliases to expand on my hosting account when I run a command like: ssh user@server "bash -c \"alias\"" My .bashrc file is: echo .bashrc # .bashrc shopt -s ...
2
votes
3answers
168 views

Do global aliases exist in bash

I wonder if it is possible to set a "global" alias in bash, like zsh's -g alias option - not "global" from the user's point of view but from the shell's point of view. What I want to know is: Can an ...
70
votes
27answers
17k views

Quick directory navigation in the terminal

I would like to frequently switch between directories that are in totally unrelated paths, for example /Project/Warnest/docs/ and ~/Dropbox/Projects/ds/test/. But I don't want to type cd ...
3
votes
1answer
163 views

code review: automatic completion for bash aliases

I was reading How do I get bash completion for command aliases? and I thought, that the answer by Shawn J. Goff needed a little something: less user setup so I wrote a little script that is intended ...
4
votes
3answers
215 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 ...
5
votes
4answers
1k views

How can I make shell aliases available when shelling out from Vim?

In my .zshrc, I declare some aliases. Eg, which dbstart shows the contents of that alias. If I open vim from that shell, it is a child process. In Vim, I can run shell commands with :! some_command. ...
1
vote
0answers
56 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
35 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: ...
12
votes
2answers
13k views

Refresh aliases and functions after defining new aliases and functions?

When I define a new alias in .bash_aliases file or a new function in .bashrc file, is there some refresh command to be able immediately use the new aliases or functions without closing the terminal ...
-1
votes
1answer
42 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 ...
4
votes
3answers
316 views

Automatically put an alias into ~/.bashrc or ~/.zshrc [duplicate]

Is there a command line util/script that automatically saves aliases? E.g. save-alias my-ip="curl ipecho.net/plain" and that will define an alias, then add/update it in ~/.bashrc or ~/.zshrc I was ...
11
votes
3answers
4k views

l, ls & la — what are the differences, and are there more of these commands?

So, through typing several commands I've found that there's not only ls, but l and la too. There doesn't appear to be any man entries on Ubuntu 12.14. They all appear to do similar things with minor ...
1
vote
3answers
103 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
42 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
24 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
28 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
116 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
36 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: ...
26
votes
1answer
5k views

How do I get bash completion for command aliases?

I am looking to get tab-completion on my command line aliases, for example, say I defined the following alias : alias apt-inst='sudo aptitude install' Is there a way to get the completions ...
6
votes
2answers
148 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
193 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
86 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
32 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
36 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
309 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
175 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
56 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 ...