Skip to main content

All Questions

Tagged with
101 votes
7 answers
37k views

How to use `which` on an aliased command?

Like most users, I have a bunch of aliases set up to give a default set of flags for frequently used programs. For instance, alias vim='vim -X' alias grep='grep -E' alias ls='ls -G' The problem is ...
Adrian Petrescu's user avatar
50 votes
5 answers
47k views

Is it possible to include file in config file of zsh? How?

I'd like to have a file eg. f with only zsh aliases (pureness reasons). Then I'd like to include f file in my .zshrc file, so that the aliases defined in f are visible in .zshrc. Is it possible? If ...
xliiv's user avatar
  • 899
40 votes
2 answers
38k views

alias vs export for simple commands

For simple commands like less, is it better to make an alias or to export the options? Is there any benefit of one over the other? For example, if I want less to always use the -R option to show raw ...
skittleys's user avatar
  • 645
37 votes
2 answers
79k views

How to reset a shell environment?

This issue has been bugging me for a while, and although I've thought I've found my answer through EnvWatcher, unfortunately it only works on Bash. And I use zsh. I would like to replicate the things ...
mhitza's user avatar
  • 566
29 votes
3 answers
30k views

Escaping quotes in zsh alias

Following on from this question about stripping newlines out of text, I want to turn this into a zsh alias as follows: alias striplines=' awk " /^$/ {print \"\n\"; } /./ {printf( \" %s \",$0);}"' I'...
Seamus's user avatar
  • 3,713
29 votes
2 answers
5k views

How to make the zsh "correct" functionality remember my spell-correction decisions

I have enabled correction (I wouldn't call it autocorrection specifically because of this issue) in zsh by enabling setopt correct in my .zshrc. Now, when I type dtae in a terminal, I get: dtae ...
shrx's user avatar
  • 445
26 votes
5 answers
14k views

Clear or disable aliases in zsh

I installed oh-my-zsh to make terminal use a bit easier. One thing that bugs me though is the prolific aliases added by it, like "ga", "gap", "gcmsg", "_", which are harder to remember than the ...
Siyuan Ren's user avatar
  • 1,382
25 votes
4 answers
15k views

Share aliases and PATH setting between zsh and bash

The shell that I normally use is zsh. I have several aliases to enable color in some programs such as ls and grep. I've also set my custom path so that I can execute programs in non-standard place (...
phunehehe's user avatar
  • 20.3k
25 votes
1 answer
5k views

how to find file defining an alias

I am having a problem I'm not sure how to get around. Somehwhere on my system, I have an alias defined as such: alias subl=\''/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl'\' I ...
Ali Samii's user avatar
  • 441
15 votes
4 answers
13k views

Using zsh autocompletion for alias

I have created a few aliases for git in zsh. For example: gch = git checkout, grb = git rebase --committer-date-is-author-date and some more complex useful zsh functions for git commands. But how can ...
Patrick Artounian's user avatar
14 votes
3 answers
8k views

Resolve all aliases in a zsh command line

I have nested aliases and I want to resolve all of them before executing the command. How do I do that? If there is a function that is not bound to any keys then M-x foobar is fine for me too. I ...
WeSenseASoulInSearchOfAnswers's user avatar
12 votes
5 answers
1k views

How can I "stack" shell aliases?

In my .profile (sourced in sh emulation mode from my .zshrc) I have the following snippet: if [ -f /usr/bin/pacmatic ]; then alias pacman=pacmatic fi # Colorized Pacman output alias pacman="...
strugee's user avatar
  • 15.1k
11 votes
3 answers
6k views

Difference between alias in zsh and alias in bash

I have searched around but could not find anything conclusive. Is there a difference between the alias command in zsh and the alias command in bash? If not, does it mean I can share a set of aliases ...
Zameer Manji's user avatar
11 votes
3 answers
1k views

Defining an alias and immediately use it

In zsh this works fine: alias foo=ls foo But this does not: alias foo=ls; foo Pressing enter an extra time is not an issue when running interactively. But when running through ssh it suddenly ...
Ole Tange's user avatar
  • 35.8k
9 votes
3 answers
6k views

sudo: nocorrect: command not found

I am using zsh and oh-my-zsh on Arch Linux. I am not able to make directory using mkdir edward@ArchLinux ~ $ sudo mkdir -p /samba/raspberry [sudo] password for edward: sudo: nocorrect: command ...
Alex Jones's user avatar
  • 6,383
9 votes
1 answer
6k views

How to overwrite aliases in my shell (Oh My Zsh)?

I would like to alias my ls command, but there is a previously defined alias for it which I believe gets invoked first before my definition! I am using .zshrc to define my alias, and here is what I ...
Farhad's user avatar
  • 93
8 votes
2 answers
2k views

zsh alias expansion

Is it possible to configure zsh to expand global aliases during tab completion? For example, I have the common aliases: alias -g '...'='../..' alias -g '....'='../../..' but when I type for example ...
Bryan Ward's user avatar
7 votes
5 answers
6k views

Get the expansion of an alias (in both bash and zsh)

I want to get the expansion of an alias. For example, if I have: alias g=hub alias cdh='cd $HOME' I want to have: expand_alias g == hub expand_alias cdh == cd $HOME The tricky thing is that the two ...
Tom Hale's user avatar
  • 31.2k
7 votes
3 answers
1k views

What is causing `diff` to run `git diff`?

I'd like to use diff as described here and in the documentation I see when I type man diff. However, when I type diff, what I get is this: ~ ❯❯❯ diff usage: git diff --no-index <path> <path&...
Ben Saufley's user avatar
7 votes
5 answers
6k views

Is it possible to define directory-sensitive aliases in zsh (or any other shell)?

I want to use different aliases (or perhaps: the same alias differently) depending on the current working directory. For example, I might want to use l as a shorthand for ls with some extra options. ...
k.stm's user avatar
  • 719
7 votes
1 answer
6k views

Zsh - alias -s with parameter

In zsh, I can specify default program to open which file extension like alias -s {mkv,mpg}='mplayer' . I runs fine but what I really want is to run mplayer <filename> & so it won't produce ...
Dzung Nguyen's user avatar
6 votes
2 answers
4k views

Make "." and "source" default to ~/.zshrc

I would like to source my ~/.zshrc by running . with no arguments. So this: $ . should do this: $ . ~/.zshrc I would like the normal functionality of . to remain unchanged. The only difference ...
Resigned June 2023's user avatar
6 votes
1 answer
3k views

What's the intended use case for COMPLETE_ALIASES in zsh?

For some months now, I have had setopt completealiases in my .zshrc. I haven't the faintest idea why I added it - most other things have comments or can be understood from neighbouring settings. ...
muru's user avatar
  • 73.9k
6 votes
1 answer
3k views

Run one command after another in zsh when Ctrl-C is pressed

I have recently moved to zsh from bash (on OSX). I have an bash alias I have used to run one program then another (even if previous program exits with error) on bash. I can't work out how to ...
ravenshill's user avatar
5 votes
3 answers
6k views

Automatically put an alias into ~/.bashrc or ~/.zshrc [duplicate]

Is there a command line util/script that automatically saves aliases? E.g. save-alias my-ip="curl ipecho.net/plain" and that will define an alias, then add/update it in ~/.bashrc or ~/.zshrc I was ...
Don Manley's user avatar
5 votes
2 answers
3k views

Forward aliases to child process

I have some aliases which are defined in /etc/zprofile (or /etc/profile for bash). Also $PATH gets manipulated there. I want to start an interactive shell from a shell which avoids the $PATH ...
pseyfert's user avatar
  • 888
4 votes
1 answer
584 views

How to trigger a 2nd command when a specific command is run in the shell?

I'll explain my question with example. I run $ python manage.py to perform some action. I want to run another command $ xyz , just when any user runs the previous command. Thus, from now on, ...
yask's user avatar
  • 153
4 votes
3 answers
8k views

zsh alias being overridden somehow

I'm on a system running OS X 10.8.5. I recently tried to alias ls to ls -G -la command. I opened up ~/.zshrc, put in the alias, relaunched the terminal, but the change didn't take effect. Upon ...
Jules's user avatar
  • 2,104
4 votes
3 answers
2k views

Automatically source a file when `cd` into a specific directory

I have couple of utility commands-and-aliases that are generic enough in any directory for my own requirement. But there are certain directory e.g. 'build', where I need a custom behaviour. To do this,...
mtk's user avatar
  • 27.8k
4 votes
4 answers
5k views

Does Bash and Zsh have a mode to echo what the alias expands to upon pressing Enter?

For example, if I have a alias dbmigrate='rails db:migrate' is there a mode or simple way to configure in Bash and Zsh so that when I type in the shell: $ dbmigrate # press Enter it will echo ...
nonopolarity's user avatar
  • 3,109

15 30 50 per page