Stack Exchange Network

Stack Exchange network consists of 174 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
66 views

How to write Bashrc with and without sudo for different use cases? [on hold]

I'm searching through a ton of packages between a vm and host to see which package is causing text input issues for steam. I frequently need to check for and install packages on the guest machine and ...
3
votes
3answers
606 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
361 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
35 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
15 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
49 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
0answers
24 views

Is there a way to set coloring for “cd tab” complete on macOS?

I have turned on coloring, set colored-stats on in my ~/.inputrc but still not working, here is a screenshot, first one, cd tab & second is ls tab
0
votes
2answers
47 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
48 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
17 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
34 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
28 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 ...
0
votes
3answers
68 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
414 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/...
0
votes
0answers
11 views

Unable to source file with aliases in zsh on MacOS [duplicate]

I have created a file with some aliases that I need to from time to time. These aliases are simple kubectl port forwarding commands. For the test purpose, I have left only one alias in the file: ...
2
votes
1answer
126 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
120 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
39 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
833 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
84 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
97 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
42 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
172 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
143 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
78 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
45 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
79 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
49 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
181 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
33 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
26 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
37 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
43 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=...
0
votes
1answer
54 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
103 views

Always exclude path in find command

I have a directory whose contents should never be found by find, so I aliased find like this: alias find='find -not -path "*.sync*"' the issue is that find now complains that operators are not ...
6
votes
3answers
754 views

Bash shadow a command - function with same name as command [duplicate]

I have a function in my .bashrc to automatically sudo to open files that aren't writable by me: vim() { if [ -w "$1" ]; then \vim "$1" else sudo env HOME="$HOME" \vim -u ~/....
4
votes
2answers
1k views

Making alias of rm command [duplicate]

Making alias of rm command so that when rm command is executed it will first copy file to /tmp/recycle_bin and then remove the file. But I'm getting issue in the process. Steps performed by me: I ...
0
votes
2answers
88 views

Alias when not first word: `G='|grep'` then `command G grep-string`

I find myself typing | grep and | less a lot, and was wondering if there was any way to be able to do something like: alias G='| grep -E' # egrep is deprecated alias L='| less' So I could do ...
2
votes
1answer
295 views

Create a recycle bin feature without using functions

I am working on an old linux learning project and one of the tasks is as outlined below: "Create an alias that protects files from permanent deletion my moving them to a directory called .Trash. ...
1
vote
1answer
44 views

Aliased an awk command successfully now won't use OFS [closed]

So I was able to get a command finally with the ability to get and grep the information from a specific file I wanted and then I ran into a problem with alias: find ./ -type f -name filename.ext -...
6
votes
3answers
2k views

-bash: /bin/cd: No such file or directory - automatically execute ls after cd

I accidentially destroyed my cd command. I tried to automatically execute ls after cd is called. I found a post saying that I have to execute alias cd='/bin/cd && /bin/ls', but now I get -...
-4
votes
1answer
52 views

How can I pass aliases from a shell to a script run by it? [duplicate]

$ alias alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' alias egrep='...
0
votes
1answer
48 views

.bash_profile taking in quotes into beginning of alias

Here is a snippet from my .bash_profile: alias hi=“echo hi” alias oe=“open -e” alias u=“cd ..” alias uu="cd ../../“ alias uuu=“cd ../../../“ If I attempt to run a command using ...
1
vote
2answers
116 views

find inside shell function

I try to put find inside function and catch an argument passed to this function with the following minimal work example: function DO { ls $(find . -type f -name "$@" -exec grep -IHl "TODO" {} \;) ...
2
votes
1answer
80 views

Possible to make zsh up-arrow history search detect aliases?

I have git aliased to g. Sometimes I use g, and sometimes I don't. I might run git add file1 and later g add file2. When I want to add file1 again, I might type g add in the zsh prompt, and then ...
1
vote
2answers
49 views

The alias does not work ?

I create an alias in ~/.cshrc like this alias bw "bjobs -w | awk '{print $7}'" but it doesn't work at $7. How do I fix this ?
1
vote
1answer
115 views

creating alias in bashrc in wsl [duplicate]

I'm trying to create alias for for cd command to AppData and %programdata% folders but I got path not found while if I write manual it works, here is what I'm doing: In .bashrc I do alias client= '...