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.

82
votes
8answers
93k views

How can I install the `ll` command on Mac OS X?

I'm using Mac OS X. When I SSH into servers I find the ll command useful, but it's not available on my local machine. How can I install it?
5
votes
2answers
2k views

sudo: nocorrect: command not found

I am using zsh and oh-my-zsh on Arch Linux. I am not able to make directory using mkdir edward@ArchLinux ~ $ sudo mkdir -p /samba/raspberry [sudo] password for edward: sudo: nocorrect: command ...
0
votes
1answer
24 views

Is it possible to give alias name to ip address with port number in CentOS 7

I have one question regarding given alias to ip address with port number. For example I am executing jenkins in my local system in port number 8080 and nexus in port number 8081. I will accessing ...
0
votes
1answer
39 views

How can I automatically fix cd typos?

I often type quickly and will mistype cd ../ as c d../, and for some reason on most of the Linux servers I work on that gives about a 4-5 second delay before telling me it was wrong. Is there a way to ...
3
votes
2answers
3k views

/etc/hosts in debian resets itself on reboot

I've been having a problem where when our vps provider decides to restart the server (running Debian 5.0.8), the server fails to remember changes to /etc/hosts. All I need is an database alias that ...
0
votes
1answer
44 views

Make alias for shell scripts

I'm working my way through the Wicked Cool Shell Scripts book. I've created a script, following the book's code, which can be found here. I'm trying to make an alias for this script so I can just call ...
0
votes
0answers
11 views

Printing output in full screen with auto detect for putty screen size

Using the following alias I were able to achieve BTC current price from Binance exchange. alias binance="curl -sS 'https://api.binance.com/api/v1/ticker/price?symbol=BTCUSDT' | jq -r '.price | ...
51
votes
3answers
59k 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
vote
1answer
15 views

Setting up aliases for a history expansion pattern

similar to the existing $_ which I learned stands for !-1:$, I would like to create aliases for $__, $___ and so on which refer to the 2nd or 3rd -last command. I have tried adding alias "$__"='!-2:$'...
0
votes
1answer
29 views

Expand alias in ZSH history

I have the following alias in my zshrc alias nif='nvim $(rg --files | fzf -m || echo +qa)' Essentially, I use rg (ripgrep) to show all the files in the current directory and in sub directories. This ...
3
votes
2answers
144 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. ...
1
vote
1answer
55 views

alias to turn on/off openvpn

I do have a list of *.ovpn configuration inside the directory of /etc/openvpn/ovpn_tcp/ inside that directory i do have a bash script called go include the following code which will pickup random ...
2
votes
1answer
176 views

egrep in bash script not working

I have this set of commands : s3ls="aws s3 ls $ssyss3/ --recursive --human-readable --summarize" egrepCommand="egrep '$currentDate|Total'" totalSize=$(echo $s3ls|$egrepCommand| awk -F 'Total Size:' '{...
0
votes
1answer
44 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
2answers
39 views

Why can't tcsh do a single-line 'which -> vim' command?

I often have to do which command, and then open it in vim to actually see what's inside. I'd like to have an alias or function that does this, with tab completion. Here's what I've tried: superwhich()...
1
vote
0answers
28 views

Tab complete global alias names not at the beginning of a line

I have a bunch of aliases like this alias -g foo=cmd1 alias -g faz=cmd2 alias -g fam=cmd3 At the shell (I'm using zsh) I want to be able to type echo fa<TAB> and be prompted for faz or fam ...
0
votes
1answer
31 views

Short command or alias to copy last command to clipboard

Often I'd like the command I just typed to put into the clipboard, and I'd like to do it from the command line. I came up with: alias cl="fc -ln -1 | sed 's/^\s*//' | xsel -b" To alias cl to that ...
5
votes
1answer
155 views

Different output when alias

I have a command set as an alias like this: alias badalarm="cat ~/sagLogs/* | grep -I 'failed to generate expected' | awk '{print $4}' | sort | uniq | tee /dev/tty | wc -l" It gives me this output: ...
0
votes
2answers
78 views

find exec does not work with command aliases?

macOS Trying to do a find with a -exec of a command aliased in my .bash_profile , find shows find: [alias cmd]: No such file or directory e.g. find ./ -iname *.doc -exec sha256 {} \; where alias ...
253
votes
19answers
176k 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 ...
5
votes
1answer
1k views

Writing bash function as one-line alias

How do I write this as an alias? p() { DIR=~/projects/$@ pushd "$DIR" } This is as far as I got, but it's piping stdin to pushd instead of xargs: alias p="xargs printf ~/projects/%s | pushd"...
0
votes
1answer
37 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/...
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
29 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
111 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 ...
0
votes
1answer
107 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
290 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 ....
22
votes
2answers
37k 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
85 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
43 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 ...
1
vote
3answers
68 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
17k 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
65 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
59 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
52 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
927 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
49 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
243 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
123 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 ...
119
votes
35answers
56k 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
18 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
433 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). ...