alias

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

Is there a way I can use .bash_aliases in a shell-scripts? 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. Asked By: nath || Source Non-interactive shells don’t expand aliases by default. …

Total answers: 1

Show Shell Function in Ubuntu Terminal

Show Shell Function in Ubuntu Terminal Over the years I’ve moved away from using aliases to defining functions in a .functions file that I source at the time of launching the shell. This works fine, but one feature of alias that I miss is being able to see what a particular function does. Example: Alias: …

Total answers: 2

changing grep command –color from red to another color

changing grep command –color from red to another color I’m searching from the file using grep command with particular pattern, sysadmin@localhost:~$ grep bash /etc/passwd which return the output like below root:x:0:0:root:/root:/bin/bash operator:x:1000:37::/root:/bin/bash sysadmin:x:1001:1001:System Administrator,,,,:/home/sysadmin:/bin/bash How can I change the default color of red to something different (eg.blue) Asked By: SpiderMan || Source The simple solution: …

Total answers: 1

Custom alias to run and compile .c file

Custom alias to run and compile .c file I’m trying to create custom alias to to compile and run my .c files in one command. I tried to add this line in /.bashrc_aliases alias runc=’gcc $1 -lm && ./a.out’ however I get an error and it seems like the .c file doesn’t get passed to …

Total answers: 1

Should I put functions in .bashrc, .bash_aliases or .profile

Should I put functions in .bashrc, .bash_aliases or .profile I have read this thread about where to put aliases. Now, let’s suppose that my custom command is quite elaborate (takes arguments in input, is composed of several commands run one after the other, I want to preserve it multi-line for clarity’s sake, involves quotes, double …

Total answers: 2

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

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=" echo "${PWD}/" " But it doesn’t work properly. Instead …

Total answers: 1

alias defined in .zshrc does not propagate to shell script

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 Python 3.11.6 (main, Nov 2 2023, 04:39:43) [Clang 14.0.3 (clang-1403.0.22.14.1)] on …

Total answers: 2

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

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 any of the places I’ve learned aliases can be stored, including: /etc/profile /etc/zsh/zprofile (which …

Total answers: 1

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

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 file? The hostname is defined in ssh config …

Total answers: 1

Alias for git commands

Alias for git commands Most of the time, I use these git commands : git add src/ package.json git commit -m "custom message" git push origin "name_of_the_branch" So I want to make a single alias command which should look like: git_alias src/ package.json && "custom message" && name_of_the_branch By running the above alias, it should …

Total answers: 3

Create a bash function with parameters to use as an alias

Create a bash function with parameters to use as an alias I have realised that my folders follow a specific structure and wanted to access them with cd faster, so I tried to make this alias / function that would behave like this: cdc glm 03 would be equivalent to cd ~/Documents/7glm/week03 And I tried …

Total answers: 1

Converting a tcsh alias into zsh

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 change the directory to /Users/myself/Document/Folder/. How could I "convert it" to the zsh shell? Asked By: leparc || …

Total answers: 1

nushell – how to list aliases?

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 2023-08-15 20:04:36 nushell 0.83.1-1 /home/rne〉$nu.scope.aliases 2023-08-15 20:04:39 Error: nu::shell::column_not_found × Cannot find column ╭─[entry #13:1:1] 1 │ $nu.scope.aliases · ─┬─ …

Total answers: 1

How to config alias on RedHat server?

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 TIME CMD 1332818 pts/55 00:00:00 bash [username@machinename: ~]$ echo $$SHELL 1332818SHELL [username@machinename: ~]$ echo $- …

Total answers: 3

how to add alias to bashrc and load content with sudo?

how to add alias to bashrc and load content with sudo? I need to run my script with sudo, because it includes commands for installing programs with apt. So I do this: sudo ./myscript.sh With content: #!/bin/bash # add alias .bashrc (work) echo "alias myupgrade=’sudo aptitude -y safe-upgrade && sudo updatedb’" | sudo tee -a …

Total answers: 1

How to printf "`" and "%" character inside array on aliasses?

How to printf "`" and "%" character inside array on aliasses? I have some issues with the button on the keyboard, I have already replaced my keyboard 3 times. I use printf for some text editors temporarily. I need to printf "`" and "%" characters inside the array with colour on aliasses, not working at …

Total answers: 2

Command doens't work when aliased

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 command is simple, it runs two …

Total answers: 1

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

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 … ls … realpath … I have tried …

Total answers: 4

What overwrites an alias created by a file in /etc/profile.d? (environment variables)

What overwrites an alias created by a file in /etc/profile.d? (environment variables) I executed the following command to create an alias file in CentOS 7.9: echo ‘alias ll="ls -alhF –color=auto"’ > /etc/profile.d/alias-ll.sh Then once I restarted the shell, "type ll" indicated that this alias did not work. I thought this may have been due to …

Total answers: 1