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

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
35 views

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

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/...
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
98 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 ...
-1
votes
1answer
41 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
67 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? ...
0
votes
1answer
36 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 ...
0
votes
1answer
57 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
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
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
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
429 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 ...
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
410 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
279 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
45 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 ...
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
2answers
57 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 "没有那个文件或目录" ...
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
86 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
26 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 ...
3
votes
3answers
893 views

How to create an environment variable that is the output of a command

How do I create an environment variable that is the result of a specific command? Specifically, I want an environment variable ($BWD) that is the basename of $PWD $ cd /home/devel/Autils/lib $ echo $...
9
votes
2answers
391 views

How to create alias with a command contains ' and "

A few posts ago someone asked how to show memory in percentage. Someone replied with: free | awk '/^Mem/ { printf("free: %.2f %\n", $4/$2 * 100.0) }' I was wondering if I can turn this command into ...
0
votes
1answer
62 views

What is the best way for storing and versioning his aliases/functions/symlinks?

actually I have these lines (exemplary) in my .zshrc file: . ${TOOLS_HOME}/cli/.cli_base . ${TOOLS_HOME}/cli/.cli_functions . ${TOOLS_HOME}/cli/.cli_symlinks This works fine so far. My only problem ...
0
votes
0answers
19 views

Ending slogin session with exit command freezes due to PROMPT_COMMAND modification

I recently embedded an "alert" command into my PROMPT_COMMAND to give me a little notify-send screen notification with the exit code of each command (because I always forget to append the alert when a ...
0
votes
1answer
53 views

Linux “alias” command question [duplicate]

Where any aliased command is stored? If I am aliasing "ls" as "l" then where will that aliased be stored? Does it affect .bashrc or .cshrc?
0
votes
2answers
54 views

How do I put an argument into the BROWSER variable?

I like to be able to do export BROWSER="lynx -cfg=~/.lynx.cfg". I tried this directly, and I also tried setting an alias alias lynx="lynx -cfg=~/.lynx.cfg", but these didn't work. (Meaning that tools ...
0
votes
2answers
181 views

How to find out where my alias are defined in CentOS? [duplicate]

I'm a CentOS user. In my machine, some aliases are available, they were previously defined in the past. I want to add new aliases to function as shortcuts to frequently used commands. I don't know ...
0
votes
1answer
22 views

Date not updating in .alias

I have an alias file with the following line: alias ss="import /home/User/Pictures/screenshots/screenshot-$( date '+%Y-%m-%d-%H-%M-%S.png' )" In terminal, when I type "ss" it runs the command and ...
0
votes
2answers
107 views

Why is an alias in a script being sourced in an interactive bash process not expanded?

$ alias bb=hello $ cat test.sh #! /bin/bash alias bb echo "$bb" $ ./test.sh ./test.sh: line 3: alias: bb: not found Is it because alias is not inherited by a child bash process for the script ...
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 ...
0
votes
1answer
48 views

Touch and open file in same command alias [duplicate]

I find myself typing these commands a lot (on Mac): $ touch example.txt $ open example.txt I was wondering if there was an easier way to do this. I tried this: $ alias t='touch $0 && open $...
0
votes
3answers
53 views

Is there a way I can tab between screens without pressing ctrl-a tab every time?

Essentially I just want to press Ctrl+Tab, not Ctrl+A then Tab. I don't believe this can be accomplished with an alias, but have read some stuff about maybe using stty? But I've never used stty and ...
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 ...
4
votes
3answers
434 views

Use alias and carry it on

Let's say I have this alias in my .bashrc alias somedir="cd /var/www/site" how can I use somedir in say ... a cd command? e.g. cd somedir/app/ doing this currently returns: -bash: cd: somedir/...
2
votes
1answer
299 views

OpenBSD - How does one set an alias?

I am running the latest OpenBSD and I cannot figure out how to set a simple alias, something along the lines of cls=clear. I've tried putting it in ~/.cshrc and in ~/.profile. I've tried: alias cls ...
0
votes
1answer
431 views

bash: alias: : not found

I am using ubuntu 18.01,when I add below command to ~/.bashrc with vim: # myself add alias lsa='ls -lart'   alias lsl='ls -lrt'    alias lm='ls -al|more' for example: # some more ls aliases alias ...
1
vote
2answers
58 views

How do I update this recursive directory file search for input and name outputs to handle the below case

I am updating a script that recursively goes through a directory and ocrs the pdf and updates the pdf. In its simple version, it works. ocrmypdf -l vie --deskew --clean --force-ocr --sidecar ...
2
votes
3answers
1k views

type ls command [duplicate]

so i studied somewhere about the type command and came to know that type command can provide the location of command used with it,more specifically the location of the executable file associated with ...
0
votes
1answer
132 views

Matlab application command alias creation error in Ubuntu 18.04

I had installed MATLAB 2017b in my Ubuntu 18.04 PC and am able to execute it as : sudo /usr/local/MATLAB/R2017b/bin/matlab -desktop I intend to install another version sometime in the future as well....
2
votes
1answer
193 views

Using heredoc in zsh aliases

I would like to use heredoc in a zsh alias, for example: alias runthing="cd ~; date << HERE date HERE" However every time I run this alias, the shell acts as if I have not terminated the ...
0
votes
2answers
195 views

Configuring .ssh/config to forward host aliases to a remote host?

We use jump hosts to access our hardware. These hosts are short-lived (less than a day), and are different every time they're generated. I would like to be able to configure my local .ssh/config file ...
0
votes
3answers
413 views

Why doesn't root alias vi to vim if it's standard for other users?

On centos (and I believe many other distros) vi is aliased to vim for all users by default. However, for whatever reason vi is not aliased to vim for the root user, something that always annoys me ...
1
vote
1answer
310 views

How to use aliases with auto completion in oh-my-zsh?

I'm using zsh on MacOS El Capitan. I'm wondering how auto completion has to be parameterized to resolve aliases as well. When I used bash, my .bash_profile contained the following: alias mdb "mongo -...
0
votes
2answers
118 views

To create an alias for grep and to exclude svn directory

To create an alias for grep and to exclude svn directory (currently no questions cover this) on bash env I did: $ function gp {grep -rnIi --exclude-dir='.svn';} However, I get error bash: syntax ...
3
votes
1answer
63 views

How can I alias a history expansion in zsh?

I want this to work (it needs extendedglob and histsubstpattern): alias ri='^(#b)E(?)^E${(l:2::0:)$((match[1]+1))}' But it doesn't: $ alias sss='^(#b)E(?)^E${(l:2::0:)$((match[1]+1))}' ...
1
vote
3answers
132 views

tcsh alias with complex cmds, quotes and cmd arguments

I'm tying to alias a set of pipe commands, went thru some of the threads here and found that cmd line should be used differently. instead of $1 use !:1 but it doesn't seem to work for me in the below ...