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
0 answers
6 views

Expand bash alias inline VScode's integrated bash terminal [migrated]

Ctrl + Alt + E is the default key binding for doing an inline bash alias expansion, and it works fine if I open a WSL terminal outside of VScode. However, I don't seem to find a way to expanding a ...
ricardo3889's user avatar
0 votes
0 answers
28 views

Configure zsh syntax highlighting for bash-my-aws

I have been using zsh syntax highlighter from this repo and it has been very great so far. Now, I discovered a repo called bash-my-aws which aliases my awscli commands to a more usable and compact ...
Rynn_'s user avatar
  • 1
0 votes
1 answer
125 views

Expand variable to alias and execute

I have an alias set in my .bash_aliases file to execute neovim. I can successfully use this alias from the command line however I cannot use this alias via a variable (ie the EDITOR variable - set in ....
ljden's user avatar
  • 103
1 vote
1 answer
89 views

How do I make a Subshell a part of an alias?

I'm not sure what is the correct way to describe my problem, so here's an example: alias ashell='adb shell su $(stat -c %u /data/data/com.termux) -s /data/data/com.termux/files/home/bin/termuxshell' ...
Dr. Coomer's user avatar
-1 votes
1 answer
223 views

making it so alias's work in shell scripts?

So I don't have python available as a command on my system but I do have python3. So I did alias python=python3 and I was able to then do python test.py insead of just python3 test.py. I then created ...
neubert's user avatar
  • 6,919
0 votes
1 answer
107 views

How can I make a bash script alias that accepts inputs?

I currently have a bash script that starts up a python file like so #!/bin/bash echo "Starting main.py in Production folder" cd Production python main.py main.py is actually supposed to ...
frend123123's user avatar
1 vote
2 answers
289 views

How to have bash aliases usable from any directory?

As title sais I want to be able to use bash aliases from inside directories other than home. If file structure looks something like /home/Documents, do I have to create another .bash_aliases folder ...
frend123123's user avatar
1 vote
1 answer
219 views

Git Bash : neither .bash_aliases nor .gitconfig read automatically

I'm setting up a new computer, and, among other things, Git with Git Bash. I copied my .bash_aliases and .gitconfig from a previous computer, but I can't get Git Bash to source them automatically. ...
Charles's user avatar
  • 225
0 votes
1 answer
788 views

Aliases for going to directory of a file and executing command in that directory

I am trying to write two command aliases one to take a file not directory path and cd into its directory. My attempt below is. alias godir='cd $(dirname $1)' however this leads to bash cd: {file path}...
MANICX100's user avatar
  • 358
0 votes
2 answers
37 views

Bash recognizes function argument as a program

I'm pretty new to the syntax of bash and I have a piece of code in my '.bash_aliases' file. It either gets an integer as an argument or the letter 'c', when it gets an integer, it puts that integer in ...
Casper2416's user avatar
6 votes
1 answer
2k views

How to use alias inside another alias in ZSH?

Let's say I have the following alias definition in my ZSH config file: alias myalias="cd /" how can I use myalias inside another alias? ie: alias myaliasone="myalias && cd /usr&...
ReynierPM's user avatar
  • 363
0 votes
1 answer
34 views

Can no longer open terminal after editing my bash_aliases

I edited my bash_aliases to have a new alias (stars block out my email for privacy sake): alias t_cluster="u*******@notchpeak.chpc.utah.edu" I then mistakenly added this to my bash_aliases (...
Taliamycota's user avatar
1 vote
2 answers
261 views

Why fish shell does not allow function named `-`

I am trying to use fish as my default interactive shell. I was previously using bash and there was support for alias named - (ASCII hyphen, 0x2d). Why does not fish allow creation of alias or function ...
jiwopene's user avatar
  • 351
1 vote
0 answers
656 views

How to escape slashes in bash alias name?

I want to make an alias like this: alias /sbin/init="/path/to/my/script/sh" However, when I try to source my .bashrc, it throws an error: -bash: alias: `/sbin/init': invalid alias name How ...
Andy Mac's user avatar
0 votes
1 answer
48 views

How to create complex alias (start Ember, start Rails, and change directory) in Ubuntu 20.10.4

I'd like to use an alias to start my Rails/Ember app, open a new terminal tab and cd into the Ember directory. I use Ubuntu 20.10.4 and the default Terminal. This is what i have so far: alias ...
Pida's user avatar
  • 107
0 votes
1 answer
408 views

How to get my bash alias to run when I open terminal

I setup a bash alias to run neofetch in .bash-alias but the only way to get it to run is to source it in every new terminal window. How can I get it to actually run when the terminal starts/opens? ...
bckelley's user avatar
2 votes
1 answer
4k views

Alias CMD command from WSL2 shell

I'm running WSL2 on Windows 10, and I want to be able to run a CMD command from it without exiting the Linux shell. Specifically, I want to do: wmic diskdrive get Model,Manufacturer,Size,DeviceID,...
Hashim Aziz's user avatar
  • 12.1k
1 vote
1 answer
347 views

Migrating aliases from bash to zsh

I recently moved from bash to zsh. Everything is great, I love it! Except some of my old aliases are getting confused. I have a long list of aliases like this that I've just migrated wholesale from ....
Oh My .zshrc's user avatar
0 votes
3 answers
318 views

Creating an alias that is an incomplete command

The documentation from tldp.org doesn't really specify when or how the bash interpreter replaces an aliased string. I'm looking for information on how to create an alias that is an incomplete command. ...
Brydon Gibson's user avatar
0 votes
1 answer
139 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 ...
inspirednz's user avatar
3 votes
3 answers
720 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). ...
psycho9o's user avatar
0 votes
1 answer
144 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. ...
ryanw's user avatar
  • 103
5 votes
4 answers
3k 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 ...
Thomas's user avatar
  • 509
0 votes
1 answer
319 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 ...
ExceptionInTheRye's user avatar
1 vote
1 answer
2k 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 -...
Nathan Mills's user avatar
3 votes
1 answer
513 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....
Syed Ali's user avatar
  • 173
4 votes
0 answers
1k 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 ...
svidgen's user avatar
  • 141
2 votes
1 answer
68 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 $...
tonyWaldheim's user avatar
2 votes
1 answer
164 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 ...
Kir's user avatar
  • 23
-1 votes
1 answer
428 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 ...
xkeshav's user avatar
  • 355
1 vote
1 answer
67 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 ...
Sepehr Nazari's user avatar
8 votes
6 answers
3k 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 ...
phenomenon's user avatar
2 votes
3 answers
711 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" ...
Nerdy Cat's user avatar
10 votes
2 answers
4k 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/...
WestCoastProjects's user avatar
5 votes
1 answer
5k 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 ...
Galen's user avatar
  • 153
0 votes
1 answer
164 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 ...
prubini87's user avatar
  • 155
21 votes
1 answer
11k 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 ...
BBales's user avatar
  • 313
8 votes
2 answers
752 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 ...
iLikeDirt's user avatar
  • 333
83 votes
3 answers
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=...
Requist's user avatar
  • 930
2 votes
0 answers
1k 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.
LookingToLearn's user avatar
0 votes
2 answers
124 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"...
Flowinho's user avatar
1 vote
3 answers
662 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 ...
Utkarsh.K's user avatar
0 votes
1 answer
2k 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 ...
shickmo's user avatar
5 votes
1 answer
10k 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 ...
kleinfreund's user avatar
  • 2,391
0 votes
0 answers
490 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 ...
user9623's user avatar
  • 153
0 votes
1 answer
101 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 ...
AstroSnail's user avatar
1 vote
1 answer
2k 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 ...
Greg M's user avatar
  • 113
2 votes
1 answer
201 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 ...
Bugs Bunny's user avatar
0 votes
1 answer
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 ...
alle_meije's user avatar
0 votes
1 answer
364 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?
Fernando's user avatar
  • 263