Skip to main content

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
1 answer
163 views

Bash alias is not executing as expected

Having read a little of alises, I wanted to try one but I couldn't get it to work. Why does this alias not work? $ printenv PWD /home/vm $ alias testpwd="$PWD" $ testpwd -bash: /home/vm: Is ...
john smith's user avatar
1 vote
2 answers
1k views

/etc/zshrc is not applied when log in

I have no idea why having aliases that are applied to all interactive terminal (i.e., my user account and sudo) is so difficult. Most web search result were about BASH, but my shell is ZSH (Manjaro ...
Damn Vegetables's user avatar
0 votes
5 answers
260 views

Whitespaces in alias bashrc

I use Bash I wrote a command for printing only docker id separate with whitespaces on one line. docker ps -a | grep -E '^[a-z0-9]{12}' -o | awk '{printf "%s ",$0} END {print ""}' ...
Admineral's user avatar
0 votes
1 answer
45 views

Primitive Alias doesn't work in Bash [duplicate]

I wrote the following rather primitive alias: alias unshorten="curl -k -v -I $1 2>&1 | grep -i '< location' | cut -d ' ' -f 3" It's meant to unshorten the shortened link and then ...
Sir Muffington's user avatar
1 vote
2 answers
351 views

Rename terminal title && run application using alias

Trying to create a command that rename terminal title and run a application, I'm adding the commands inside .bash_aliases file. The rename command I'm using is: PS1='\[\e]0;test\a\]${debian_chroot:+($...
raijin's user avatar
  • 13
0 votes
3 answers
257 views

How to avoid nesting root shells? (POSIX)

Consider the following Bash alias, just something that came to mind quickly, and I did not have time to dig further: alias su='sudo -s' Note, that I am running Bash, though I would like the solution ...
Vlastimil Burián's user avatar
1 vote
2 answers
554 views

Do bash aliases only work at beginning of line?

First, I ran touch file.txt Next, I ran these commands: alias xx="file.txt" vim xx Expected behavior: vim loads file.txt. Actual behavior: vim loads a new file xx. Why? Is it because ...
WalksB's user avatar
  • 145
1 vote
0 answers
965 views

Multiple hostnames for a single IP address in local network

I'd like to know if it is possible to have multiple hostnames for a single IP address in my local network, so that all hostnames point to the same IP-address (kind of an alias) Example: name ...
Rudolf Ziegaus's user avatar
0 votes
2 answers
152 views

bash alias to randomly run a command among many

I need help figuring out how to run a bash alias or function that randomly chooses another command or alias and runs it. the list of commands and aliases and function aliases is known beforehand. the ...
stacking and exchanging woohoo's user avatar
0 votes
0 answers
11 views

How can I make uncommon symbols more accessible?

I am using Bash in Linux, inside Termius on a smartphone. I would like to make reaching for particular symbols as fast as possible, by customizing bash to interpret certain character sequences as ...
Julius Hamilton's user avatar
1 vote
1 answer
68 views

Why does enclosing a command in double quotes affect aliases?

I have an alias rm='/bin/rm -i' and I know that if I type "rm" filename in the command line, the alias will be ignored somehow and the normal rm command without the -i flag will be called, ...
BrassPandaSax's user avatar
1 vote
0 answers
274 views

Minify bash command with arguments

Want to minify bash command using arguments. I am often checking the internet provider's and other Free and Public DNS Servers with the code below running in tmux, but wondering, how this can be ...
eapo's user avatar
  • 121
1 vote
2 answers
247 views

Kill all processes macthing a pattern, ignoring case

I want to have an alias to do something like pkill -f PATTERN but ignoring the case of the pattern. This is what I have after looking around but it's not working alias pkf="kill `ps ax | grep -i $...
user avatar
2 votes
1 answer
136 views

How to create alias with a caret^ command?

I have a workflow that first check git diff for specific file and then add it to stage. git diff .. ^diff^add I want to give these command a alias but this one doesn't work alias da="^diff^add&...
gary's user avatar
  • 23
0 votes
1 answer
239 views

Ubuntu - Run executable with customized name from anywhere

I have installed etcher and I can run it from its installation directory (.../balena-etcher-electron-1.7.9-linux-x64/squashfs-root) with the command ./balena-etcher-electron. Well wonderful ! But now ...
Mickael Evrard's user avatar
0 votes
1 answer
315 views

Add heredoc (<<) to end of alias within function call

I have an alias which is my psql connection string for a database, let's say the alias is this: alias GQQ='psql "host=$host user=$redshift_uname dbname=$redshift_dbname port=$port pass word=$...
amstergc20's user avatar
1 vote
2 answers
907 views

How can I/Should I default flags when running a command?

For context, I'm using zsh. Every time I use locate, I want to pass the -i and -A flags. Usually, if I can get away with it, I create an alias with the same name as the existing command to do this. ...
Daniel Kaplan's user avatar
1 vote
2 answers
389 views

zsh: alias or shell function to only echo its command line, including shell control characters

Using zsh, I'd like to create an alias or a shell function that operates as follows: I want this alias or shell function to echo its command line without honoring any shell control characters such as &...
HippoMan's user avatar
  • 647
0 votes
1 answer
57 views

Bash set project-specific aliases, file not found

I am on Windows and using GitBash to run shell scripts in bash that run python scripts. How can I create a project-specific alias to define a specific python environment and run shell scripts through ...
a11's user avatar
  • 103
1 vote
1 answer
157 views

How not to use nested strong quotes (')

I'm a relatively new user of zsh and don't know too much about shells (unfortunately). Nonetheless, I would like to define an alias in my .bashrc containing a hash. However, zsh doesn't seem to like ...
pahohu's user avatar
  • 111
0 votes
0 answers
301 views

Custom alias outside .zshrc but ZSH_CUSTOM doesn't work in kali

For reference this is not a duplicate: I reviewed other Q and A like this but it doesn't work for me. Background: I'm using Kali in parallels. To keep my .zshrc file tidy I decided to mkdir ...
ShifraSec's user avatar
1 vote
3 answers
3k views

How do I make an alias for a command with sudo

I want to add two aliases, so one executes a command when non sudo, and the other executes a command when sudo, like this: alias v = 'nvim' alias 'sudo v' = 'sudo -E nvim ' I also have set alias sudo=...
Ramita's user avatar
  • 11
2 votes
0 answers
89 views

"Could not find foo in PATH" - but it's right there

I see the following behavior: $ foo Could not find foo in PATH $ which foo /usr/local/corp/bin/foo $ readlink -f `which foo` /path/to/opt/foo/foo $ /usr/local/corp/bin/foo starting foo, output for foo,...
einpoklum's user avatar
  • 9,636
0 votes
1 answer
61 views

How do I exactly alias this one liner in bash?

bash alias doesn't like the quotes dpkg-query -W -f '${Installed-Size;8}kb ${Package} ${Version} ${Status}\n' | sort -n | column -t | grep -Pv "(lib*)" | fzf
genggi's user avatar
  • 1
1 vote
1 answer
263 views

fish shell: universal variables and alias not shared between "contexts"

I use fish shell mainly from Rider IDE and iTerm2. I've noticed that every task that implies saving something for future sessions will not operate transparently between the two aforementioned contexts....
Lord of the Goo's user avatar
1 vote
2 answers
109 views

like history and fc but for a personalized list of useful commands

I have spent a few hours trying to get an easy access to my most useful commands I have to use in a certain environment, I have the "incredible" idea of using history for that purpose, to ...
JustLolo's user avatar
0 votes
0 answers
55 views

Korn shell (ksh) omits closing quote when displaying aliases

When displaying aliases in Korn shell (ksh) the closing quote is omitted. This happens with both predefined and user-defined aliases: >> alias type r l ltr type='whence -v r='hist -s l='pwd; ls ...
KS_on_StackExchange's user avatar
0 votes
2 answers
2k views

How to pass stdin to python script

I'd like to pass input from a shell command over to a python script in an alias that uses a shell command. test.py: import sys print(sys.argv) the alias alias foo='echo $(python test.py $1)' since $ ...
Brian Barry's user avatar
1 vote
1 answer
170 views

How to send output to next input line?

This my snippet alias hst="history 1 -1 | cut -c 8- | uniq | fzf ". when I run hst The output is $ ~ hst (the output from hst) $ This is what I want $ ~ hst $ (the output from hst) Example ...
Jamm Utkarsh's user avatar
0 votes
2 answers
150 views

How to get 'man gfind' when I enter 'man find'?

On my new-ish mac os/Darwin system, my find tool is an 11-year-old BSD version. I have used MacPorts to install a more current version: GNU's find, which MacPorts has named gfind, and placed in /opt/...
Seamus's user avatar
  • 3,062
1 vote
1 answer
141 views

Bash Alias with Multiple Quotes [duplicate]

As part of my workflow, I tend to ll (alias ll='ls -l') into a directory to see if the files I need are there, and after that, I cd into the same dir to do whatever I had to do. I would like to add an ...
Jesus DA's user avatar
0 votes
0 answers
354 views

Alias added to /etc/bash.bashrc does not work for Debian 11

I have a Debian docker. In one line I define an alias in Dockerfile: RUN echo alias Kill="ps -ef | grep 'dotnet' | grep -v grep | awk '{print $2}' | xargs -r kill -9" >> /etc/bash....
Saeed Neamati's user avatar
0 votes
1 answer
352 views

Bash alias with a loop, a sudo, pipes, flags, single quotes and double quotes

I want to make a bash alias of the following command, which works typed out on the command line but all my attempts at making an alias have failed. My only diagnosis is that all those nested quotes ...
Heathcliff Huxtable's user avatar
-1 votes
1 answer
846 views

New Fish-Shell Aliases are ignored

as explained in https://stackoverflow.com/a/2763014/2891692 i created for days many alias in my config file ~/.config/fish/config.fish and it works. every new alias i add today don't work. Example of ...
SL5net's user avatar
  • 103
0 votes
0 answers
202 views

using 2 alias together in cshell terminal

lets say I have 2 aliases, each having multiple arguments. It looks somewhat like below example alias s1 "command1 -a -b -c" alias s2 "command2 -d -e -f" now if I run :s1 s2 in ...
Krishanu Banerjee's user avatar
0 votes
1 answer
1k views

alias in ash - limitation, syntax issue?

I'm running OpenWRT in a NAS (WD-MBL) and putting together a set of aliases to make maintenance easier via the command line. These work as expected: alias shutdown='sync && wait && ...
Groucho's user avatar
  • 31
0 votes
1 answer
147 views

Replace text in terminal

I am using secure copy to copy some data from a server to a folder (let's say: scp [email protected]:/project1/data/ data1/). My question is if it is possible to save the address of the server (in the ...
Avles Edivad's user avatar
0 votes
1 answer
193 views

Usig zsh glob variable not expanding inside alias

I want to list and sort by time, all the files matching a certain pattern and then get only the first 20: ls -laths *.txt | head -20 This works well, for example if I create two files: touch 1.txt ...
Santiago's user avatar
  • 418
1 vote
0 answers
791 views

When does /usr/share/zsh/vendor-completions get loaded?

As far as I can tell, my .zshrc doesn't manually source anything in /usr/share/zsh/vendor-completions. If I try to write, in my .zshrc, an alias for a command that has completions set up in /usr/share/...
2rs2ts's user avatar
  • 163
-1 votes
1 answer
943 views

bashrc + why source not refresh the .bashrc file

we add the following line to bashrc file alias reboot="echo you not allowed to do reboot on this machine - sorry" so we get more ~/.bashrc # .bashrc # User specific aliases and functions ...
yael's user avatar
  • 13.4k
0 votes
1 answer
2k views

error using scp in alias: not a regular file

I know questions regarding this error have been asked before - but I can't seem to figure out why this isn't working in this case: for aliases. I have the following alias scpip='scp $1 [email protected]:~' ...
Brian Barry's user avatar
0 votes
2 answers
1k views

How do I create a command prefix for bash with an alias?

I'm trying to create a bash alias that would act as a prefix, and could be parsed without needing to use a space. Basically, I have a set of commands that all start with the same first few characters, ...
saya's user avatar
  • 1
5 votes
1 answer
1k views

bash_aliases and "if [ -f ~/.bash_aliases ]; then . ~/.bash_aliases fi" meaning

There's a short section in my .bashrc file that I don't understand and I'd like to ask what it means and some syntax explanation. # Alias definitions. # You may want to put all your additions into a ...
michal roesler's user avatar
3 votes
1 answer
213 views

Making simple backup alias / function?

OK, so all I really want to do is backup single files as a time in the current directory with '.bak' extension. Here is my current function that does this (jsyk, using Rocky Linux): function backup { ...
GregTheHun's user avatar
4 votes
3 answers
3k views

Paths as bash aliases only work in parent directories?

Can bash aliases be paths? Hi and sorry in advance for the noob question. I noticed a strange behavior when using bash aliases. My goal is to use short bash aliases for often used paths, to make ...
weygoldt's user avatar
0 votes
0 answers
105 views

How to run only a single command in linux?

I want to execute a single command with .bashrc or dotfile support. For eg: Opening Firefox browser by typing firefox. I don't want to open terminal, then execute the command and then exit the ...
atg greg's user avatar
0 votes
1 answer
718 views

change rm alias to mv

Reference: how to change `rm` to as a command like `mv ~/ .trash` I would like to implement recycle bin utility in UNIX since UNIX not has one. In .bashrc file I change alias rm='move.sh" as per ...
Rocky's user avatar
  • 3
-1 votes
1 answer
150 views

Escape character(single-quotes) not working in Linux alias

I was trying to play around with escape characters in aliases. Here's a simple example : I want to create an alias for echo 'Hello' So I wrote the alias like below : alias sample 'echo \'Hello\' ' But ...
Sanjay Rajashekar's user avatar
0 votes
2 answers
64 views

How to extend a wild card option to include js and ts

I have an alias set as follows: alias ppp='prettier --write "**/*.js"' I want it also to do all my .ts files. I'm quite inept at wild card expressions sadly.
Peter Kellner's user avatar
0 votes
1 answer
427 views

Variable sleep bash alias [duplicate]

So, I'm trying to create an alias which will run a command after sleeping x seconds. alias ls_sleep="sleep $1 && ls" The problem is, $1 is being passed as string and things like $(($...
alex_pc89's user avatar
  • 101

15 30 50 per page
1
2
3 4 5
19