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.

2
votes
1answer
38 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
51 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
40 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
41 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
424 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
22 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
343 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
269 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
44 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
34 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
25 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
45 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
64 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
22 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
189 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
810 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
382 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
60 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
51 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
51 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
133 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
21 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
46 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
40 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
52 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
105 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
423 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/...
3
votes
1answer
252 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
343 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
50 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
115 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
162 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
126 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
344 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
263 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
102 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
57 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
114 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 ...
14
votes
4answers
4k views

Would globally aliasing the fork bomb prevent its execution?

If you were to globally set alias ':(){ :|:& };:'='echo fork bomb averted' would that be an effective security strategy to avoid the Bash fork bomb execution or would there still be a way to ...
0
votes
2answers
64 views

Setting an alias when double quotes and single quotes both fail

This question is not a duplicate of Why alias behave different than running bash command directly? because I have tried that solution and it hasn't worked. I replaced all my single quotes with double ...
1
vote
4answers
301 views

Get the expansion of an alias (in both bash and zsh)

I want to get the text which an alias expands into. For example, if I have: alias g=hub alias cdh='cd $HOME' I want to have: expand_alias g == hub expand_alias cdh == cd $HOME The tricky thing ...
0
votes
0answers
37 views

What is the correct way to assign a function containing chained commands to an alias in .bashrc?

I wish to invoke an alias as follows: alias_name arg0 arg1 arg2 arg0 = filename arg1 = General string arg2 = String representation of last command The aim is that by calling the alias and passing ...
1
vote
1answer
28 views

OS X command as an Alias fails with the error '9:13: execution error: The variable Base is not defined. (-2753)'

I have a command I'm running in OS X. It works perfectly: $ osascript -e 'quit app "Base"' && cd /Users/davechambers/Library/Android/sdk/platform-tools/ && ./adb pull data/data/uk.co....
1
vote
1answer
55 views

Where to define shell aliases in configs for projects in tmuxinator?

I define Bash aliases in my ~/.tmuxinator/*.yml files like this: pre_window: alias cc=heh/path/that;alias ccc='cc clean; clear; cc' ;alias selenium-restart=bin/docker/restart-selenium-chrome ;alias ...
0
votes
1answer
49 views

Shell Script To CD and Run a Python Script

OK, I know that there is a lot like this question but I literally get nothing. The thing i need is a script that cd's to /home/project then runs python3 pyscript.py I created an alias to cd alias name=...