Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
The results are in! See what nearly 90,000 developers picked as their most loved, dreaded, and desired coding languages and more in the 2019 Developer Survey.

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.

0
votes
1answer
34 views

Why is `which <command>` not picking up aliases?

I'm on OSX and if I run python --version in a bash shell, I get this: $ python --version Python 3.7.3 But the which python command appears to be pointing to version 2.7. $ which python /usr/local/...
3
votes
2answers
2k views

Using zsh autocompletion for alias

I have created a few aliases for git in zsh, for example gch = git checkout, grb = git rebase --committer-date-is-author-date and some more complex useful zsh functions for git commands. But how can I ...
1
vote
0answers
27 views

how to remove leading space in command line argument [duplicate]

I am losing my mind here.. have tried every combination of functions that strip whitespace but I can't get rid of this particular whitespace I want to write a convenience alias so that typing runit ...
1
vote
3answers
96 views

How can I make an alias that has an executable's name

I tried to implement the following line in my .bashrc, alias ./my_exec='printf "foo"' However, the alias doesn't work, and the following line appears : bash: alias: `./my_exec': invalid alias name ...
250
votes
19answers
171k 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 setup ...
0
votes
1answer
62 views

Accessing memory of parent process from child process

Say I login using bash and I define an alias. $ alias c=clear $ echo $0 bash Now I enter dash. $ dash $ echo $0 dash The alias defined in bash isn't available: $ alias $ How do I access it? ...
1
vote
1answer
279 views

Bash aliases not loaded on Debian, but on Mint they do when sudo -s

The very same ls aliases are defined on both machines: $ cat ~/.bash_aliases | grep -e "alias ls=" -e "alias l=" -e "alias lll=" alias ls='\ls --kibibytes --color=always --group-directories-first' ...
1
vote
2answers
380 views

find command throws errors when inside function

I can run the following command in bash without any errors: $ find /d/Code/Web/Development/Source/ \( -name '*.cs' -o -name '*.cshtml' \) -exec grep -IH UserProfileModel {} \; I wrote a function in ....
20
votes
2answers
36k 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
84 views

change permissions to a file and everything inside , recursively

So I want to create an alias called changeAllPermisions that accepts one parameter argument in such a way that when changeAllPermissions argument is called , both Group and Other do not have access to ...
-1
votes
1answer
40 views

What command is my alias running? [duplicate]

In this question it is recommended repeatedly that to figure out where an executable is located, one should run command -v file. I've tried running command -v ls on a few different systems now and I ...
0
votes
1answer
35 views

error while using sed in tcsh alias

I am unable to "source/run" my tcsh alias, which is as below: alias inp1 "grep -i "final_model" /scr/cb2TempProd/tmp/$USER/\!:1/Simulation/Input/assemble.preprocessing | sed 's#.*<##; s/>$//'" ...
1
vote
3answers
44 views

How to convert an alias for bash to an alias for csh? -> Or to tcl

alias s2st="ps -A | grep -E "a|b"" works for bash. Then I tried to convert it for csh: set-alias t2st 'ps -A \| grep -E "a\|b"' But csh does quoting so different, I couldn't coupe with... How ...
2
votes
1answer
39 views

How to make alias interpretive?

I have a list of servers I often connect to, named like server001, server002... server999. I don't want to store 1000 alias hardcoded with these server names. I also don't want to write a function and ...
20
votes
4answers
16k views

Is it possible to include file in config file of zsh? How?

I'd like to have a file eg. f with only zsh aliases (pureness reasons). Then I'd like to include f file in my .zshrc file, so that the aliases defined in f are visible in .zshrc. Is it possible? If ...
0
votes
1answer
56 views

How can I run multiple unix commands sequentially using a single shortcut command?

I usually go through files using the following commands: cd first pwd ls cd second ls This a more generic way of my work. Can I execute all the commands one by one by itself by calling "some secret ...
0
votes
1answer
57 views

How can I improve below alias?

I want to run less -F command on latest updated log file of one binary (which creates logs with names which start with xtest*) which is in logs directory. I was able to create below alias in csh, but ...
0
votes
1answer
46 views

-bash: alias: /Users/username/.bash_profile”: not found

I'm trying to add some aliases to my bash profile, but it's not working for some reason and I get these errors when I open a new terminal or execute bash profile with . ~/.bash_profile. These are ...
0
votes
1answer
917 views

creating shortcuts in Mac OSX at command line [closed]

I run a MacBook Pro with yosemite OSX. I'm trying to create shortcuts to go to certain directories, run script files, etc. This is my first attempt at creating shortcuts/aliases. I'm asking in this ...
5
votes
3answers
3k views

Only if in “/” : alias ls='ls -I test'?

I have the following in my ~/.bashrc to hide the listing of test from the output of ls: alias ls='ls -I test' But I want it to only hide test if my current working directory is the root (/) folder, ...
0
votes
1answer
1k views

How to execute an alias, encapsulated in another source file?

For instance ~/.cshrc: alias job_start 'cd $PROJ_DIR && source .env/bin/activate.csh && rehash && job_run' $PROJ_DIR/.env/bin/activate.csh: alias job_run '(cd $PROJ_DIR/...
0
votes
3answers
45 views

are there side-effects to remapping/aliasing less to vim?

I added the following to .bashrc to remap less to vim alias vsi='vim -R -c ":map Q :q!<enter>" -' # Vim Standard Input [readonly] alias less='vsi' the reason is that I don't want to maintain ...
0
votes
2answers
234 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 ...
3
votes
1answer
2k views

how to add parameter to bash alias without space in between? [duplicate]

We can do with ease: myalias='command param1 param2' then myalias param3 runs command param1 param2 param3 I need an alias which will run the same, but without the last 'space': command param1 ...
1
vote
3answers
112 views

SSH with Command Doesn't Run as an Alias

I have the following command to remote into a local server and tail -f the latest log file for an application that I have. The command works perfectly fine from the command line - ssh user@hostname ...
118
votes
35answers
55k views

Quick directory navigation in the bash shell

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 /[full-path]/...
0
votes
0answers
17 views

Using Alias for allowing a user to delete in a specfic directory and not prompting for a password

Need to allow a single user to delete folders / files within one directory, I have tried a few ways with and without alias but both ways it either prompts for a password or allows the user to remove ...
5
votes
1answer
428 views

Unexpected behavior of Bash script: First executes function, afterwards executes alias

When I execute the following script #!/usr/bin/env bash main() { shopt -s expand_aliases alias Hi='echo "Hi from alias"' Hi # Should Execute the alias \Hi # Should Execute the ...
4
votes
1answer
1k views

Run command with sudo by default

I need a linux user (lets call him "bob") who is allowed to run a list of commands which require root privileges. So let him be required to run /sbin/firstcommand and /sbin/secondcommand (which are ...
2
votes
2answers
1k views

awk function with a number parameter for the column you want to print

I want to use my awk shortcut as a function, so that I can pass the column number which then prints me the output. My aliases are: alias A="| awk '{print \$1}' alias G="| grep -i' Instad of typing: ...
1
vote
1answer
1k views

Use aliases as custom commands in terminator

I am using a terminator layout to start multiple terminals, and would like to call an alias at each terminal start which is defined in my .bash_aliases (called by both .bashrc and .profile). ...
0
votes
2answers
53 views

How to get file path which was selected and make copy in dolphin KDE and paste on zsh?

➜ ~ cat .zshrc | grep xclip alias c="xclip -selection c" alias -g v='"$(xclip -selection c -o)"' ➜ ~ v zsh: 没有那个文件或目录: file:///home/roach/Downloads/pure.png ➜ ~ The Chinese words "没有那个文件或目录" ...
1
vote
1answer
25 views

Modifying the default bashrc alert command

I was scrolling through my bashrc (bored) and I got interested in the alert command that is concatenated in there by default. It's practical and everything, but it requires you to type ; alert at the ...
6
votes
2answers
400 views

bash aliases do not expand even with shopt expand_aliases

I want to run an alias inside a bash -c construct. The bash manual says: Aliases are not expanded when the shell is not interactive, unless the expand_aliases shell option is set using shopt In ...
4
votes
2answers
278 views

Aliased pipeline using head and cut

I'd like to create an alias to have a quick view of the table format files with comma separator: alias thead='head | cut -d, -f1- | column -s, -t' Later using it like this thead file.csv However, ...
2
votes
1answer
48 views

map ls -a to ls -A

I have tried to made an alias ls -a = ls -A, ending up with: bash: alias: `ls -a': invalid alias name I want ls -a without . and ... How can I get that?
1
vote
1answer
42 views

Alias to prompt for tab completion for a set of directories?

Is it possible to make a bash alias, which would be able to prompt me for tab-completion of a set of directories? let's say I have a number of source code controlled projects, main path of each ...
21
votes
4answers
3k views

Automatically detect when I typed “vi” but meant “cd”?

About 5 times a day, I type "vi" when I meant "cd", and end up opening a directory in vi. It's making me NUTS. It seems like there should be a way to detect when I type in "vi + directory" and ...
2
votes
1answer
27 views

Executing linux aliases from sqlplus

In sqlplus there is an option to execute standard shell commands, simply by prefixing them with '!'. Example: SQL>!ps -af returns expected processes. My question is, is there an option to execute ...
0
votes
0answers
18 views

Unalias the Unalias command [duplicate]

Lets say that I put alias unalias='echo bob' in my bash.rc file, how could I without an editor unalias unailias.
2
votes
2answers
84 views

Grep Ignoring Pipe?

I'm trying to pipe the output of a grep search into the input of another grep. Such as: grep search_query * | grep -v but_not_this But the second grep is not using the output of the previous search. ...
0
votes
1answer
34 views

Input manipulation for an alias [duplicate]

man -k '^printf' lists man pages specifically available for printf utility only, printf(1) and printf(3) in my PC. If you do not mention these signs around printf, the command doesn't work. I want to ...
0
votes
1answer
24 views

set alias to read variable and then use in second command; only works when I execute them manually

I am with CentOS 7 and I want to bind an alias to launch PostgreSQL shell(psql). I defined this alias and append it in /etc/profile.d/alias: alias psql-local="read -p \"PSQL: enter the DB to connect: ...
7
votes
1answer
191 views

Insert a user defined variable in an alias in Bash

I would like to add an alias to a command in my .bashrc file, as in this example: alias take_row="cat prova.csv_001.txt | awk -v nrow="${nrow}" '{if (NR==nrow) print}'" But I would like to specify ...
8
votes
3answers
4k views

How to alias cp with cp -i by default

Is there a good way to alias the command cp file1 file2 to cp -i file1 file2?
17
votes
2answers
932 views

How to retrieve lost aliases?

I made an echo command to my .bash_aliases file and erased all of my aliases, except the test alias. However, I still have a session open that has the aliases loaded (into the tcl?). Can I retrieve ...
1
vote
2answers
789 views

deferring argument in “alias” in .bashrc

I work with LINUX (ubuntu 14) My newly purchased laptop forces me to use the bash shell, and it has .bashrc. I used to use the C-shell before that and tried to copy its aliases from .cshrc to .bashrc ...
-1
votes
2answers
685 views

alias for killing all processes of a grep hit [duplicate]

I am trying to make a superkill alias that kills all process that hit a grep match. I'd like to do: superkill ruby And have it kill all processes that match 'ruby' In my .bashrc, I've added this ...
0
votes
0answers
29 views

Creating alias with single parameter used in multiple places

I am trying to create a simple alias for SSH-ing to a host, like the below: alias wpessh='ssh $1@$1.ssh.wpengine.net' I also tried using a function as suggested by other answers here: function ...
5
votes
5answers
2k views

What are commands to find shell keywords, built in functions and user defined functions?

I was discussing with my friend on how the commands are parsed in the shell, and he told me that bash searches the command in following order List of aliases List of shell keywords List of ...