Questions tagged [bash-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 in the command-line and avoid having to remember complex combinations of commands and options. Use this tag for questions about using aliases with the bash shell.

Filter by
Sorted by
Tagged with
0
votes
1answer
40 views

Why is /bash_aliases creating this error when sourced?

I have a .bash_aliases file I've been using for a long time. Today I added some commands that are broken into multiple lines (using \). Since doing that, I can't source the file to reload it. When I ...
3
votes
3answers
354 views

Alias to source .bashrc after it's been edited?

I would like to add an alias (for convenience sake) that would allow me to edit my bashrc, and if changes were made, source it, but if no changes were made, don't source (in case I changed my mind). ...
0
votes
1answer
49 views

How to escape this command to add alias in .bashrc?

I want add alias command to .bashrc. the command like this : xev | awk -F'[ )]+' '/^KeyPress/ { a[NR+2] } NR in a { printf "%-3s %s\n", $5, $8 }' I am confused to escape character from that command. ...
5
votes
2answers
647 views

Space in doskey/alias for windows?

I try to run Laravel's Artisan command inside the (docker) container by defining a doskey alias. My idea was: php artisan=docker-compose exec apache php artisan $1 However it does not allow me to ...
0
votes
1answer
69 views

How to automatically add characters to the user input before command execution

I love reading on the terminal - it focuses my attention and lets me read twice the amount I used to read on browsers, etc. I wrote a script using alias for bash.bashrc that changes the working ...
1
vote
1answer
1k views

Alias file not working in Bash on WSL (Opensuse Leap 42.3)

I have my alias file set up like so in Bash in WSL: alias gvim='/mnt/d/Vim/vim81/gvim.exe' alias vim='/mnt/d/Vim/vim81/vim.exe' alias pngcrush='/mnt/c/Users/nathan/Downloads/pngcrush_1_8_11_w64.exe -...
3
votes
1answer
161 views

Alias for sudo then ssh

I am looking to write an alias for the following two command: sudo su - user ssh somewhere I've tried alias jump='sudo su - user; ssh ' and then use this as jump somewhere but this doesn't work....
1
vote
0answers
51 views

Can I create aliases with make?

Is it possible for make to create aliases? Here's what I tried: Makefile aliases: alias hello='echo world' alias holy='echo cow' It doesn't work as-is, presumably because the alias command ...
2
votes
1answer
57 views

Automatically list contents of directory when changing to it

I am a huge fan of the ~/.bash_aliases file and I am trying to get the cd command to automatically list the contents of a directory when I change to it. In my .bash_aliases file, I put alias cd='cd $...
2
votes
1answer
78 views

How to correctly do the aliasing for whois

I'm trying to get this alias to work. alias awhois='whois -h whois.cymru.com " -v $1"' But bash doesn't give the same output. # awhois 8.8.8.8 Error: no ASN or IP match on line 1. AS | IP ...
-1
votes
1answer
127 views

cd displays the list of files and folders in macOS

Recently I have updated macOS and Terminal and below is the details macOS Sierra 10.12.6 Command Line Tool Version 9.0 Now whenever I run cd in the Terminal it navigated to that directory and ...
1
vote
1answer
50 views

How does bash alias understand “$@”?

I am trying to write an alias to do 2 things $alias cde='cd "$@" && echo' but for some reason when I call it with $cde test test all that happens is it echos test: It looks like my ...
8
votes
6answers
2k views

Creating alias for Trash

I am a newbie. I set an alias in .bashrc file as follow. alias myrm='mv /home/user/Trash/*' The purpose is that when I use myrm comment, for example $myrm foo, the file "foo" has to be moved to the ...
2
votes
3answers
442 views

How to append a string to a bash command line?

I am sure this is a recurrent question but I failed to find one that had an answer that would fit my problem. What I want to do is something like this: alias disexit = " & disown & exit" ...
9
votes
2answers
2k views

Alias does not “override” PATH entries?

The last line of my .bash_profile is: alias cp=/usr/local/bin/gcp However that is being squashed by the entry in my $PATH : $which cp /bin/cp 11:54:32/OCspark $type cp cp is aliased to `/usr/local/...
5
votes
1answer
2k views

Using alias to echo backticks in bash

Apologies if this is answered elsewhere, I could not for the life of me find a solution to my particular case, which is a bit strange I admit. (Note: all the “Using” words in this post appear blue for ...
0
votes
1answer
88 views

How to create custom alias for gnuwin32 tools in Windows Powershell

I have gnuwin32 installed and appended to my environment so I run linux/unix "ls" when I type ls in the command prompt. That's not a problem for Powershell, apparently, but I'm not being able to ...
19
votes
1answer
6k views

Bash is slow to start because of this line in .bashrc. What could cause this?

My .bashrc file contains a line to this effect: alias prog="/path/to/script.sh $(find $(pwd) -name prog)" When I comment out this line, Bash starts almost instantly when I open a new terminal. With ...
8
votes
2answers
612 views

Can I make bash stop parsing and validating a certain alias?

I'm using Fedora 25, and have added the following alias to my bash profile: alias releasenotes="dnf updateinfo --refresh info `dnf check-update | cut -d '.' -f 1 | xargs` | less" (I can't use ...
83
votes
3answers
5k views

How to unalias a minus?

My morning coffee hadn't reached my brain yet when I forgot the quotes in: alias grep="grep --color=always" so instead I typed: alias grep=grep --color=always leaving me with: --color=always grep=...
1
vote
0answers
636 views

How to chain a command after sudo su?

The idea is simple, for example: alias foo='sudo su foo && cd /tmp' However, it does not execute commands after switching users. In this case, it switches users but does not cd into /tmp.
0
votes
2answers
83 views

Bash profile commands with multiple "'` issues

Good day! I'm currently trying to get the following alias to work. 'git_fetch' and 'git_tree' are custom alias so dont worry about them. alias git_workspace='osascript -e 'tell application "Terminal"...
1
vote
3answers
312 views

Want to prevent accidental shutdowns, reboot, etc by aliasing commands such as shutdown

I am trying to alias commands such as shutdown, reboot, etc. I am aware that this is not a fool proof way to block access, however this is just to prevent accidental execution. I have looked at ...
0
votes
1answer
770 views

Is it possible to setup bash aliases that work in conemu as they do in cygwin?

So I have conemu setup to use cygwin as my shell and have it using the specified home directory I setup in my .bashrc file in /home of my cygwin directory. Here is what I have setup in the ...
1
vote
1answer
6k views

Windows 10 Ubuntu Bash: Aliases not working (: command not found)

I started the Ubuntu bash on Windows that was shipped with the Anniversary Update 1607. This bash sources the .bashrc file located at /home/phil which is the home directory of the Unix user, not the ...
0
votes
0answers
412 views

how to shorten git to g by using a alias

I am running git 2.7.2.windows.1 and I have edited my .bashrc file to have this line alias g='git' but when I type g status I get an error bash: g: command not found I even tried editing my global ...
0
votes
1answer
58 views

Alias to attempt mounting multiple times doesn't work correctly

I have the following in my .bashrc alias ext='sudo mount /dev/sd'{b..d}'1 /ext/hdd || sudo' I intended the alias to mount my external hard drive without having to worry about the semi-random ...
1
vote
1answer
549 views

Why are spaces not allowed while setting up aliases in .bashrc

Coming from the Windows world, I tend to type cls to clear the console. I wanted to set up an alias so cls would still work. I read an article online that mentioned you cannot have spaces between the ...
2
votes
1answer
141 views

Bash alias/function to precede every “git diff” with “clear”

Every time I do git diff I'd like my bash to do clear & git diff instead. I tried to tweak an answer at "Bash: Spaces in alias name" like this: git() { if [[ $@ == "diff" ]]; then ...
0
votes
1answer
2k views

Bash autocomplete behaviour in Debian 8

On a new install of Debian 8 (Jessie) I have found that the autocompletion in bash, using the tab key, has changed. The test I did was: Open a terminal (in my case Konsole). Above the prompt it ...
0
votes
1answer
204 views

Is there a standard place to put my Aliases? bashhrc vs. bash_aliases

Is there a standard place to put custom aliases? If not, what are the benefits and disadvantages of .bash_aliases, .bashhrc, and .bash_profile?
0
votes
1answer
44 views

Distribute session-only git configuration on ssh login

I have a bunch of development servers (linux) that I connect to via SSH from linux workstation. On most of these servers I want to use the Git command line interface. I use a set of Git aliases that I ...
1
vote
0answers
92 views

How to automatically log-in to remote MySQL instance via ssh behind another host?

I have an alias set up to ssh to a remote machine through a proxy ... alias sshcmd='ssh -t davea@proxy ssh destmachine' but I want to set up an alias where I ssh into the remote machine and then ...
2
votes
2answers
82 views

One-line code in bashrc to edit pdf

I would like to have a one-line code in bashrc, for removing the first page of a pdf. The command to be typed in the bash prompt could of the form: cut name.pdf This command should remove the ...
0
votes
1answer
626 views

Alias to connect to AWS instance via SSH not working

I made an alias to make it easier to connect to my AWS EC2 instance. Although there is an error. Here is the code in ~/.bash_profile: alias aws_connect=‘ssh -i /path/to/keyfile.pem ec2-user@xx.xxx....
0
votes
1answer
81 views

exiting current terminal in a script

I have made alias for running certain program and i have put it in .bashrc file. I want to close current terminal inside the script. I've tried this but it is not working. alias mp='java -jar ...
-1
votes
1answer
787 views

how to escape '$' in an awk statement in shell alias

I'm trying to write an alias that will kill all running php processes.. this is the command i got in my ~/.bash_profile alias killphp="ps aux | g [p]hp | awk '{print $3}' | xargs kill -9" this ...
0
votes
1answer
467 views

Alias not working

I have an alias that does an ssh into a machine and executes 1 line of code as following: alias posts-update= 'ssh user@host.com "cd /var/www/blog/posts && git pull"' This works perfectly if ...
1
vote
2answers
3k views

Sudo doesn't work on Aliases [duplicate]

I have added alias ll='ls -la' in /etc/bash.bashrc but sudo ll is not working. Is there a way to "source" bash.bashrc? In a related post, another user suggesting creating an alias for sudo with a ...
0
votes
1answer
88 views

Trouble 'generating' bash aliases

In my ~/.shortcuts, I have symlinks to some frequently used directories. In .bashrc (OS X), I am doing this: ls -1 ~/.shortcuts | xargs -I {} alias {}="'cd -P ~/.shortcuts/{}'" When I run alias in ...
0
votes
2answers
818 views

Run bash_aliases on start

I have a separate file .bash_aliases , in the same directory as .bashrc, that I wish to be ran on start, I've added the lines: if [ -f ~/.bash_aliases ]; then . ~/.bash_aliases fi to my .bashrc ...
1
vote
1answer
2k views

Where is virtualenv's deactivate defined?

Virtualenv defines an alias for the command deactivate as seen in yourvirtualenv/bin/activate.csh. What I'm curious about is where deactivate resides, because when I issue an alias command deactivate ...
53
votes
8answers
131k views

How can I use a Bash-like shell on Windows?

I use Linux and a Mac, and I'll be teaching some command line stuff soon. What can I install on Windows to give me a terminal window most similar to a basic Mac/Linux Bash shell? I would like to ...
1
vote
1answer
3k views

Terminal not working: -bash: exit: with: numeric argument required what to do?

I was trying to install F# compiler and interactive on my Mac, and part of the installation process required providing aliases in the bash profile file. I suspect that I messed something up here, ...
3
votes
1answer
1k views

Bash LS Options ~ Group Directories First

Locally I'm running Debian stable ~ bash -version 4.1.5 ... Remotely my server is running Centos 5-8.el5 bash -version 3.2.25 ... I have a .bash_alias file on both distros containing an alias 'll' ...
1
vote
1answer
558 views

Advanced alias in zsh shell

I'm using the zsh shell on ArchLinux and I want to know if there's an easy way to make "advanced" aliases. Normal aliases work just fine. However I can't find a way to create an alias for a ...
0
votes
3answers
93 views

Alias to add .mylongwebsiteaddress to end of lines in cygwin

I have a server called someserver and a website called mylongwebsiteaddress.com. Basically I always type $./somecommand.sh someserver.mylongwebsiteaddress.com in cygwin when doing updates to servers. ...
3
votes
9answers
9k views

Command to search programs in Linux

Do you have any easy idea to define some alias in .bashrc for finding some command that you want to search (when you forgot its name) in your machine, visiting all "bin" directories, maybe using regex?...
2
votes
1answer
296 views

Create an alias - in Bash?

How can I create an alias named - in Bash? None of the following works: alias -='cd -' alias \-='cd -' alias '-'='cd -' with error: bash: alias: -=: invalid option alias: usage: alias [-p] [name[=...
0
votes
1answer
187 views

Alias settings not “sticking” when running Fedora in Parallels

Recently set up a Fedora 15 installation using the latest version of Parallels. Everything seems to be working fine, save for a particularly odd quirk. Whenever I set up an alias using something like ...