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.

Filter by
Sorted by
Tagged with
-2 votes
0 answers
41 views

Beginner in linux and .bash_aliases not working

I wrote this using vim and create a file with the given alias i am trying to create but when i call for the alias in home "getdates" it doesn't work
Blu's user avatar
  • 1
0 votes
2 answers
34 views

How to escape both single quotes and exclamation marks in bash

I have a long command and I just want to use alias to shorten it. But the command contains single quotes and exclamation marks. The origin command is ldapsearch -x -H ... -w 'abc!123'. I tried alias ...
Donghua Liu's user avatar
2 votes
0 answers
45 views

Can't unalias then redefine as a function in the same conditional [duplicate]

Here is a simplified implementation of an issue in my bash/zsh aliases file: alias foobar='echo bar' # this is out of my control if true; then unalias foobar echo we got inside the conditional ...
Adam Katz's user avatar
  • 4,012
0 votes
2 answers
75 views

Is it possible to use a command with an argument to trigger a bash alias?

I have a program that tries to trigger a screenlock using the following commands: xdg-screensaver lock xscreensaver -lock cinnamon-screensaver-command --lock The problem is that I'm using ...
guttermonk's user avatar
0 votes
1 answer
38 views

Zsh zinit load OhMyZsh plugin skipping aliases

I want to use these plugins using zinit to load git completions in zsh zinit wait lucid for \ OMZL::git.zsh \ OMZP::git But I don't care about the aliases, there are really too much aliases I ...
fchastanet's user avatar
0 votes
1 answer
57 views

Is there a way I can use .bash_aliases in a shell-scripts? [duplicate]

Is there a way I can use bash aliases from my .bash_aliases file within a shell-scripts? I thought of something like including source "$HOME/.bash_aliases into my script but it does not work.
nath's user avatar
  • 5,784
0 votes
1 answer
51 views

How can I call git's built-in diff command directly after configuring a different visual "git diff" substitute?

I have configured git diff to be a command that calls substitute diff for viewing file differences i.e /usr/bin/vim -dR "$2" "$3" and that doesn't work when I want to create a ...
vfclists's user avatar
  • 7,609
0 votes
1 answer
78 views

Can I reprogram the pwd command to add a trailing slash?

WHen I use the pwd command, it prints e.g /opt instead of /opt/. I would like it to print the trailing slash. However, I tried adding the following line to my ~/.bash_aliases file: alias pwd=" ...
K.defaoite's user avatar
1 vote
2 answers
94 views

alias defined in .zshrc does not propagate to shell script

I have python installed on my system as python3. In my .zshrc file I defined following alias: alias python=python3 With this, I am able to run python3 using python on the command-line: $ python ...
morpheus's user avatar
  • 115
1 vote
1 answer
100 views

How can I remove aliases "which-command=whence" and "run-help=man"?

I'm running Artix Linux and using zsh, and these two aliases return no matter how many times I unalias them or remove them from my aliasrc: run-help=man which-command=whence And they don't exist in ...
swishkin's user avatar
0 votes
1 answer
61 views

Can i used these aliases in some sort of config file?

I have many of these kinds of aliases, the part before = is the host in ssh config alias sshConfigHost='ssh -t hostname docker exec -it containerName bash' Could I add these to some sort of config ...
Nickotine's user avatar
  • 467
0 votes
1 answer
56 views

ksh88 string substitution in alias | mpv streaming [duplicate]

tl;dr how can I substitute a string (i.e. a youtube/streaming url) in an alias such as alias mpvyt='yt-dlp <URL> -o - | mpv - ' ? I live in a mezzanine studio using a M1 macbook for a ...
sylvainsab's user avatar
0 votes
1 answer
155 views

How to show help for some bash command in less (like man do) rather than print it to console

For example, there is no manual pages for trap command. Running: man trap will give: No manual entry for trap Running: trap --help will print help straight to bash console without using less like ...
Anton Samokat's user avatar
1 vote
1 answer
134 views

Converting a tcsh alias into zsh

I had a tcsh alias as follows: alias cdd 'cd `dirname \!*`' I use this to change the directory to the one containing a certain file. For instance, cdd /Users/myself/Document/Folder/File.pdf would ...
leparc's user avatar
  • 13
1 vote
1 answer
195 views

nushell - how to list aliases?

The official docs of nushell claim that one is able to list available aliases via: $nu.scope.aliases However this does not work on my Arch Linux machine: /home/rne〉pacman -Q nushell ...
Richard Neumann's user avatar
1 vote
3 answers
340 views

How to config alias on RedHat server?

I'm using a server where I'm a common user (non-sudo). I access the server through ssh. Here's the output of some commands run on the server: [username@machinename: ~]$ ps -p $$ PID TTY ...
Tien's user avatar
  • 13
0 votes
0 answers
113 views

Ubuntu WSL2 startup error "is a directory" upon adding 'alias dsa='cd /home/rj/programming' to .bashrc

I added the following alias to .bashrc alias dsa='cd /home/rj/programming/dsa' and when I type dsa in the shell, bash does indeed change to that directory but when the shell starts up I get a strange ...
lkilgoretrout's user avatar
1 vote
1 answer
315 views

Unix Command (and bash alias) or script to band/unban IP addresses in Fail2ban without having to lookup and specify "jail name"

I am creating a bash alias (or possibly a script) to ban and unban IP addresses with fail2ban on Ubuntu 20.04. The bash syntax I am using to unban IP address is: fail2ban-client set YOURJAILNAMEHERE ...
DanRan's user avatar
  • 113
-1 votes
1 answer
448 views

Sourcing alias fails - No such file or directory

I have a large number of shell scripts in a deep directory tree with varying versions. To simplify using these I added a function to create an alias (selected via command line option): function ...
symcbean's user avatar
  • 5,687
0 votes
0 answers
55 views

Bash script ignores all terminal input following an underscore [duplicate]

Goal My server manages jobs using SLURM. Each job in the queue has a job ID, which can be either a single integer or two integers separated by an underscore, e.g., 123_4. You can use scontrol show job ...
Jamin's user avatar
  • 1
0 votes
1 answer
81 views

Command doens't work when aliased

I have a command created and I am trying to convert it to an alias to make it easier to use, however I am unable to solve the problem as to how best to format it. Can you help me? The principle of the ...
vic.py's user avatar
  • 103
0 votes
1 answer
237 views

How to use alias command with a paramiko SSHClient connection?

I am trying to execute the following, with no success getting either the 'py3start' or the 'py3test' alias commands recognized - (I introduced the 'py3test' for testing purposes to check if setting ...
aeon's user avatar
  • 1
10 votes
4 answers
4k views

How can I alias `...` to `../..` in Bash?

How can I alias ... to ../.. in Bash? I am aware that other answers allow alias '...'='cd ../..' but I'd like to be able to address the directory two levels up with other commands, allowing for: cd ......
Anil's user avatar
  • 221
0 votes
1 answer
221 views

zsh: alias'd commands stop working

This keeps happening and I'm not sure why. How do I trace what zsh is actually trying to do, and why it starts ignoring my alias? ************@*******-MacBook-Pro$ reload zsh: command not found: ...
Harv's user avatar
  • 2,104
2 votes
0 answers
203 views

Order in which files within /etc/profile.d are sourced in CentOS 7.9? (for defining aliases)

I have a question related to aliases/environment variables on CentOS 7.9. I am trying to make an alias for ll with: echo 'alias ll="ls -alhF --color=auto"' > /etc/profile.d/Z-alias-ll.sh ...
Tristan's user avatar
  • 121
2 votes
1 answer
72 views

Alias + and - in zsh?

For years I've used + and - as aliases for pushd and popd in both csh and bash. I've finally given up on my Macs and want to switch to zsh but I haven't been able to find a way to make these aliases. ...
sfjac's user avatar
  • 123
3 votes
1 answer
195 views

Prevent alias expansion when alias is passed as an argument

I have two aliases: alias rm='python my/rm/script.py ' alias docker='sudo docker ' The problem is that when running the statement $ docker rm ARGS the keyword rm is being expanded as alias and docker ...
Firelord's user avatar
  • 342
0 votes
1 answer
92 views

How to navigate to a previous line in a bash script

I have a bash script with a lot of if/elif statements. Is there a way to take the output of a command, and make it execute the associated if/elif statement, rather than the default version of the ...
Lee's user avatar
  • 87
0 votes
0 answers
40 views

How to substitute one file path for another everywhere for my profile

I am using some software on a shared Linux virtual machine, and I need to create my own version of one of the software's executable files. Let's say the executable file in question is here: $...
j_manson's user avatar
1 vote
2 answers
124 views

How I alias a hostname without root access vis-a-vis gethostbyname?

I'm running a program which does (in its source code): gethostbyname("whatever"); and I want it to use the local machine's address instead. I can't change the source. If I were root, it ...
einpoklum's user avatar
  • 9,617
-1 votes
1 answer
290 views

Quoting arguments for alias commands. How does that work?

I added alias for my git log command: $ alias gl alias gl='gn -c git log -w -b -p --ignore-blank-lines --full-history' $ alias gn alias gn='git-number' -n flag of git-number command runs subcommand, ...
Eugen Konkov's user avatar
2 votes
1 answer
166 views

alias for watch command gets stopped?

I create this alias, so that aliases get expanded in the watch statement. > alias w='watch -x bash -i -c' > alias k=kubectl I execute it: > w 'k get pods; echo; k get svc' After two seconds ...
guettli's user avatar
  • 1,439
3 votes
1 answer
1k views

setting alias for sourcing a script, to run that script in jenkins with restricted permissions

I want to run source ./script_name instead of ./script_name. Can I create an alias for this ? The Jenkins job will run the script as ./script_name and I can't edit the way it will run the script on ...
Anubhav Rai's user avatar
0 votes
1 answer
164 views

Alias for the "su" Command

BASH SHELL; DEBIAN STRETCH As seen here, I've created a "seems to work OK, most of the time" alias function for the su command (actually, I'm not able to find any problems with it...yet). I'...
Digger's user avatar
  • 405
0 votes
1 answer
2k views

tilde_expand: No such user .ssh

I have this weirdest error where a single IP address with ssh would immediately return an error arthur@arthur-laptop:~$ ssh 192.168.1.85 tilde_expand: No such user .ssh I feel like it's an issue with ...
Arthur Attout's user avatar
0 votes
0 answers
42 views

How openbox knows .bash_aliases used in its autostart file

I'm using two commands in a file executed by my .config/openbox/autostart.sh which are also aliased in my .bash_alises and one of them changes from time to time. The thing is that I also use these ...
Nepumuk's user avatar
  • 717
2 votes
1 answer
218 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 ...
Marius Ardelean's user avatar
0 votes
1 answer
421 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 ...
automatix's user avatar
  • 219
2 votes
1 answer
346 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, \"...
zerberus's user avatar
0 votes
3 answers
142 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....
Harsha's user avatar
  • 3
1 vote
3 answers
144 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 ...
JS.'s user avatar
  • 111
1 vote
1 answer
448 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 ...
Safwan Hossain's user avatar
2 votes
2 answers
2k 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, ...
calexandru's user avatar
1 vote
1 answer
142 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 ...
Milad Alkhamis's user avatar
0 votes
0 answers
42 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 ...
learner's user avatar
1 vote
1 answer
260 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 ...
Alfie Stoppani's user avatar
1 vote
0 answers
76 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 # ...
anonymous's user avatar
1 vote
0 answers
110 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 ...
Visrut's user avatar
  • 137
0 votes
1 answer
161 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

1
2 3 4 5
18