3
votes
1answer
35 views

Customize bash to always include a certain parameter

When using the "ls" command, bash prints in the following format: file1 file2 file3 file4 file5 file6 file7 file8 But when given the parameter "-1", it prints: file1 file2 file3 etc... Is there ...
0
votes
2answers
53 views

How to create a permanent alias without resourcing the .bashrc-like file?

I really like bash aliases, it annoys me that every time I want to add a new alias I have type two commands: echo "alias \"short-cmd\"='long-command'" >> ~/.bash_aliases source ~/.bash_aliases ...
0
votes
3answers
54 views

Assigning a command to variable

I assign command ls to my variable my_File but when I run it as $my_File it does not work. Can you please explain why? #!/bin/bash my_File='ls -f | grep -v '\/'' $my_File
2
votes
4answers
70 views

Defining aliases for a certain directory

Is there a way to have an alias set for a particular directory and its subdirectories? I know I can put it in my .bashrc file, but I would like it only for a certain directory. Edit: what i mean is ...
1
vote
4answers
84 views

How to add an alias without directly editing the `bash_aliases` file?

Is there a way to add an alias from the command line without directly editing the bash_aliases file? To clarify, how can I make a bash script do it without having to enter something along the lines of ...
2
votes
3answers
42 views

how to prevent alias expansion by `eval` to an arbitrary alias, and keep the endless loop protection on a function?

IMPORTANT: do not use eval! (I learned this later..) In a function, eval expands sleep to its alias, so I prevent the endless loop this way: function FUNCexecEcho() { echo "EXEC: $@"; shopt -u ...
1
vote
1answer
69 views

.bash_profile alias escape quotes?

On the rare occasion I use the command line, I usually forget syntax. This is one of those times. I want to add a simple alias to my .bash_profile but no matter what quote method I use, I get an ...
1
vote
1answer
59 views

Getting sudo to work for an alias

I installed Sublime Text 3 in Fedora 20 which has got GNOME, as I couldn't get it being called from terminal I created a .bash_aliases file which a line like this: alias sublime='sublime_text' And ...
20
votes
4answers
2k views

Automatically detect when I typed “vi” but meant “cd”?

Title says it all. About 5 times a day, I type "vi" when I meant "cd", and end up opening a directory in vi. It's making me NUTS. It seems like there should be a way to detect when I type in "vi + ...
2
votes
1answer
75 views

BASH_ALIASES not equal to alias

I've just recognized that (in Debian 7, within Bash 4.2.37) the output of BASH_ALIASES isn't equal to that of alias – which, according to gnu.org's Bash Manual, should be the case: ...
3
votes
2answers
92 views

Command substitution interpreting spaces within quotes as argument separators

I'd like an alias that additionally appends itself to ~/.bashrc, e.g. function tailias { $(echo "alias $1='${*:2}'" | tee -a ~/.bashrc) } I'm using tee to split the command to ~/.bashrc while ...
2
votes
1answer
61 views

How to make an alias active in both current session and in .bashrc at same time?

I just found frequently I decide to add an alias for longer time use at the same time use it now. So I have to type the same thing twice, first in current bash session then .bashrc.
5
votes
2answers
145 views

Why does !! inside an alias not work?

I have this alias set in my system /etc/bashrc file: alias root="sudo !!" The intention of this being to run the last used command using sudo of course. When used, it of course appears to ...
1
vote
1answer
197 views

ssh into a server using .ssh/config alias & run an alias on the server in the same time

On my laptop Inside ~/.ssh/config file I have this: Host <serverAlias> HostName 127.0.0.1 #Server IP User <username> PreferredAuthentications publickey IdentityFile ...
3
votes
1answer
69 views

code review: automatic completion for bash aliases

I was reading How do I get bash completion for command aliases? and I thought, that the answer Shawn J. Goff needed a little something: less user setup so I wrote a little script that is intended to ...
1
vote
2answers
107 views

.bashrc execute command after “/bin/bash --login”

I have this alias in my .bashrc: alias s='cd ~/Documents/projects/s && /bin/bash --login && rvm use ruby-1.9' How can I execute the right part after it enters login shell (/bin/bash ...
2
votes
3answers
93 views

How to create a function based on commands not defined yet?

I have some scripts (that are out of my control) that loads some environment settings to my session. So whenever I want to load I have to execute a series of commands: export ...
1
vote
1answer
203 views

Aliases in scripts are not set globally

I know this sound really wierd but this is exactly what happens. I have my .profile and .bashrc file set up in a way that the .bash_aliases file gets executed (checked it with a echo). I do not get ...
1
vote
1answer
186 views

How to create alias to kill processes running on a TCP/IP port? [duplicate]

What I have: alias killport='sudo kill -9 `sudo fuser -n tcp $1 2> /dev/null`' Problem: Running e.g. killport 8000 doesn't appear to work, though. However, simply running... sudo kill -9 `sudo ...
1
vote
2answers
45 views

What happens to argument in alias after using it once? [duplicate]

Why does this only print arg out once? $ alias test="echo $1 $1 $1" $ test arg arg This is on GNU bash, version 4.2.25(1)-release (x86_64-pc-linux-gnu).
1
vote
1answer
87 views

Find where a bash command is defined or sourced from? [duplicate]

Sometimes I want to know what a command I type into bash actually evaluates to. Usually I can figure out the location of the executable very easily with which. $ which vim /usr/bin/vim But what if ...
3
votes
4answers
297 views

Bash aliases/functions and command line options

I want to set an alias to start nedit together with command line option -noautosave (due to text files up to 500MB). What seemed to be easy: alias nn="nedit -noautosave $1 &" just raises some ...
2
votes
3answers
145 views

Simplified navigation in terminal

I know IDEs are the wave of the future, but I always find myself coding in vim in a Linux terminal. Old dog. New tricks. Anyway, navigation becomes challenging when dealing with long package names. ...
11
votes
1answer
449 views

How can I `alias sudo !!`?

I'm trying to set an alias for sudo !! in Bash. I tried alias sbb='sudo !!', but it interprets that as a literal !! and prints sudo: !!: command not found If I use double quotes, it substitutes ...
9
votes
1answer
458 views

How many different ways can you create an “alias” in Bash?

I only know of two ways: alias foo=bar and function foo() { bar }. The reason I'm asking is that - all of a sudden in one of my bash sessions - I cannot run the ln command because bash is erroring ...
2
votes
3answers
478 views

What does ll alias to?

ll is a common alias in many linux distros. How can you tell what it aliases to? I've tried checking my .bashrc, but I am not able tell what ll is equivalent to.
0
votes
3answers
83 views

I need to turn a series of commands piped together into an alias in .bashrc

sudo ifconfig wlan0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}' The above command when run from terminal outputs the right "internal" ip address. When I try to pass as alias like: alias ...
0
votes
1answer
187 views

where to (apt-get) install aliases system-wide?

I am making a Debian package that contains bash aliases. Where should these aliases be installed, so that they are available system-wide? The "right" place would be /etc/bash.bashrc, but this file ...
2
votes
0answers
242 views

.bashrc alias not working [closed]

I have set up a few aliases in my .bashrc file, like the following: alias ras='rails server' alias res='redis-server' alias rc='rails console' alias be='bundle exec' # git alias's are as follows ...
1
vote
3answers
123 views

In bash, how can I erase an alias without logout? [duplicate]

I had an alias in my .bashrc and I really don't want it anymore. I erased the alias, but my bash already has this alias loaded. Can I erase this alias from this bash without logging out?
2
votes
2answers
43 views

How can I set a bash alias that evaluates $() when run?

I set up an alias: alias gpgagentexport="eval $(cat ~/.gpg-agent-info) ; export GPG_AGENT_INFO" However when I source my .bashrc the $(cat ...) is evaluated at that point. But I want to evaluate ...
1
vote
2answers
417 views

How do I set bash aliases and variables from within vim?

In cmdline mode, the following examples do not work for me. !alias lol='echo lol' !lol='echo lol'
0
votes
1answer
183 views

Command substitution in alias resolved in bash profile? [duplicate]

I want to make an alias for randomly changing my mac address alias chrandmac="sudo ifconfig en0 ether $(openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//')" but the command substitution part is ...
5
votes
2answers
2k views

cp -f cannot overwrite cp -i alias

In my /home/user/.bashrc file, I have those aliases to prevent mistakes: alias rm='rm -i' alias cp='cp -i' alias mv='mv -i' If I'm really sure of what I'm doing, I can overwrite rm and mv aliases ...
1
vote
2answers
157 views

How can I create an alias synonym?

I have an alias pwd How can I create another alias that is a synonym for it? For example I have alias cd1='cd ~/dir1' I want a second alias cd01 that points to the same place but I don't want to ...
1
vote
3answers
494 views

How can I use grep to search for lines that start with a certain character in bash

I want an alias ('ggg') that will look through my existing set of aliases and tell me all the ones that begin with g. I have a lot of g* aliases :) I tried this: alias ggg='alias | grep ^g' but ...
5
votes
3answers
736 views

How to set an alias on a per-directory basis?

Suppose you have an alias go, but want it to do different things in different directories? In one directory it should run cmd1, but in another directory it should run cmd2 By the way, I have an ...
10
votes
5answers
452 views

How to test for possible conflicts while using alias in bashrc?

Is there a simple way to list all the command conflicts that have occurred in the system due to the bashrc update involving alias commands? For example, someone writes alias ...
1
vote
1answer
220 views

Is it possible to use a parameter within an alias command [duplicate]

Possible Duplicate: How to pass parameters to an alias? As answered in Can less retain colored output? I want to use git diff --color=always filename | less -r to get a colored output of my ...
15
votes
4answers
3k views

How can I create an alias for a command that includes a space?

Most of my my aliases are of this form: alias p='pwd' I want to alias git commit so that it does git commit -v But trying to create an alias with a space gives an error: $ alias 'git commit'='git ...
3
votes
2answers
337 views

Are there any utilities to quickly add, list and remove command aliases?

I'd like to be able to quickly, on-the-fly add (and list/remove) command aliases so that they persist between shell restarts (as if they were added to .bashrc). Are there any ready ...
3
votes
2answers
174 views

place the aliased version of an existing command in /usr/bin/

I use Vim a lot, and I know how I can start vim in insert mode. So I have an alias named vii in my .bash_aliases file. On other hand I use Git a lot too, and I have this line in my .gitconfig: ...
5
votes
1answer
120 views

ask for comfirmation when file is replaced using a redirection

I'm a careless terminal driver scared of accidentally deleting files, hence using some aliases like alias rm='rm -i' for rm, mv, cp. How can I get a similar confirmation behavior for file redirections ...
1
vote
2answers
108 views

Cannot see aliases

I have my root user and another user testuser. Now in the .bashrc of testuser, there are some aliases like la for ls -a. But when I login to testuser and try running la, it gives me the error: -sh: ...
2
votes
3answers
905 views

Issues with .bash_profile and terminal commands

I added some data to my .bash_profile to run two aliases ruby version 19 and the proper gems. As soon as I added the data I could not longer run any commands such as the MacPorts command port nor the ...
3
votes
2answers
112 views

How can I create a “base” for other aliases to refer to and enable cd base/x command directories?

I have .bash_aliases with: alias c1='cd /home/me/code/php' alias c2='cd /home/me/code/jquery' alias c3='cd /home/me/code/ruby' alias c4='cd /home/me/code/c' How can I DRY this up and loosen the ...
67
votes
6answers
2k views

Run a command that is shadowed by an alias

Let's say i have the following alias in bash - alias ls='ls --color=auto' - and i want to call ordinary ls without options. Is the only way to do that is to unalias, do the command and then alias ...
9
votes
4answers
910 views

How can I find a rogue alias declaration?

I'm trying to find where a specific alias has been declared. I've searched all the usual places I know to look for aliases: ~/.bashrc ~/.bash_profile /etc/bashrc /etc/profile With no luck. I know ...
3
votes
2answers
533 views

List only temporary aliases in bash

I know that to list all aliases in a given bash session with alias -p. Is there a way to get a list of all the temporary aliases in a given bash session, i.e. all aliases that aren't in my bash ...
3
votes
1answer
255 views

Why are these aliases failing?

I am attempting to put some alias definitions in .bashrc. Like this: #Convienience aliases alias ll='ls -l' alias ldir='ls -p | grep "/"' #Temporary aliases alias mvFooLog='mv ~/Projects/Foo/Log.txt ...