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.

Filter by
Sorted by
Tagged with
2 votes
1 answer
138 views

bashrc alias using ticks and backticks not working

I would like to create in .bashrc an alias which executes the following: virsh list --all | sed '1,2d' | sed '/^$/d'| awk '{print $2" state:"$3" "$4}' I've tried in different ways ...
0 votes
1 answer
21 views

How to list only the aliases defined by the user?

I'm using the ZSH and defined some aliases (stored in multiple fines, that are loaded in the ~/.zshrc). That is working fine. Executing the command alias allows to list all available aliases. Now I'd ...
  • 189
2 votes
1 answer
137 views

Alias piping into awk

I am trying to create an ll with awk pipe alias. I am trying to escape the apostrophes using the following answers. alias lh= `ll -h | awk {'print $9, \"-\" ,$5, \"-\", $8, \"...
0 votes
3 answers
57 views

How to pass 2nd argument when 1st argument is defaulted to its value in command line?

cdcl() { vlog -source -lint +define+"${1:-DEBUG}" -sv "${2:-*.sv}"; } Above is my fucnction, i defined it in .bashrc file. Below is my command line % cdcl 'RANDOM' 'abc....
  • 3
0 votes
3 answers
53 views

Display alias with substitutions

Is there a way to display aliases after bash has made the substitutions? Background: I have a long alias that performs actions on a directory. alias do_it='cd my_working_dir; do_stuff' This works ...
  • 101
0 votes
0 answers
22 views

shell script does not recognize alias even source bashrc where alias are defined [duplicate]

in ~/.bashrc /etc/bashrc, I write alias multiscp='/root/deploy/multiscp.sh' and in command line, I could use multiscp like a command multiscp xxx However, in a shell script, multiscp is not ...
  • 135
1 vote
1 answer
70 views

Ubuntu on Windows Terminal Hanging After Creating an Alias for Starship Prompt

Distro: Ubuntu-18.04 (running on Windows 10 WSL2) My terminal for any new Ubuntu instance is completely frozen with the message "Vim: Warning: Output is not to a terminal" This happened ...
2 votes
2 answers
148 views

Set alias to run python venv setup based on current directory name

Can't seem to figure out what the issue is. This is on a Fedora 37 with default setup (bash, gnome, etc...). What I want to achieve is to create an alias that creates a python virtual environment, ...
1 vote
1 answer
55 views

use aliases in bash script

I use aliases in my code, it works the first time and shows the current time, but the second time, when I call it shows past time(time showed before instead of current time) GNU nano 6.2 ...
0 votes
0 answers
29 views

Last login command, alias in csh

In the C shell, how can we display the login history of a particular user using an alias in such a way that the user only enters the alias name and the number of lines to be displayed without typing ...
1 vote
1 answer
98 views

How to write a function that takes an argument string that does not need to be quoted?

I'm writing a function, adding it to ~/.zshrc on my Mac. It's in order to more quickly handle commands to youtube-dl. I have this: function dlv() { cd /Users/admin/Downloads youtube-dl ...
1 vote
0 answers
35 views

How should alias in command substitution behave?

I tested a few scripts with different shells, and the results differ. # test 1 foo(){ echo $(al);} alias al='echo 123' foo # test 2 alias al='echo 123' foo(){ echo $(al);} alias al='echo abc' foo # ...
1 vote
0 answers
45 views

can we trigger some action if we `cd` into directory? [duplicate]

I have multiple projects over various languages like JavaScript, Python. I wonder if Linux provides some functionality to trigger some actions automatically if we cd into a particular directory? For ...
  • 35
0 votes
1 answer
62 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 ...
1 vote
2 answers
101 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 ...
0 votes
5 answers
92 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 ""}' ...
0 votes
1 answer
33 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 ...
1 vote
2 answers
67 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:+($...
  • 13
0 votes
2 answers
69 views

How to avoid starting multiple nested root shells?

Consider the following Bash alias: alias su='sudo -s' The problem one might encounter is running it (that alias) while already root. Demo: $ su [sudo] password for vlastimil: # su # ...
1 vote
2 answers
141 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 ...
  • 135
1 vote
0 answers
52 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 ...
0 votes
2 answers
83 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 ...
0 votes
0 answers
9 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 ...
1 vote
1 answer
45 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, ...
1 vote
0 answers
144 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 ...
  • 121
1 vote
2 answers
62 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 $...
2 votes
1 answer
111 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&...
  • 23
0 votes
1 answer
66 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 ...
0 votes
1 answer
95 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=$...
1 vote
2 answers
184 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. ...
1 vote
2 answers
195 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 &...
  • 445
0 votes
1 answer
20 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 ...
  • 103
1 vote
1 answer
97 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 ...
  • 11
0 votes
0 answers
10 views

Creating an aliases for Google Text-to-Speech [duplicate]

I would like to use Google Text-to-Speech in the Linux terminal by simply copying and pasting text into the terminal as I would if I were using espeak. This command does what I need: gtts-cli 'hello' |...
  • 440
0 votes
0 answers
159 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 ...
1 vote
3 answers
260 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=...
  • 11
2 votes
0 answers
74 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,...
  • 8,143
0 votes
1 answer
39 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
  • 1
1 vote
1 answer
134 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....
1 vote
2 answers
47 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 ...
0 votes
0 answers
45 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 ...
0 votes
2 answers
897 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 $ ...
1 vote
1 answer
77 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 ...
0 votes
2 answers
71 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/...
  • 2,389
1 vote
1 answer
94 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 ...
0 votes
0 answers
183 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....
0 votes
1 answer
122 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 ...
-1 votes
1 answer
354 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 ...
  • 103
0 votes
0 answers
99 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 ...
0 votes
1 answer
560 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 && ...
  • 31

1
2 3 4 5
18