Skip to main content

All Questions

Tagged with
1 vote
1 answer
2k views

How to use aliases with auto completion in oh-my-zsh?

I'm using zsh on MacOS El Capitan. I'm wondering how auto completion has to be parameterized to resolve aliases as well. When I used bash, my .bash_profile contained the following: alias mdb "mongo -...
Kay's user avatar
  • 121
4 votes
1 answer
361 views

How can I alias a history expansion in zsh?

I want this to work (it needs extendedglob and histsubstpattern): alias ri='^(#b)E(?)^E${(l:2::0:)$((match[1]+1))}' But it doesn't: $ alias sss='^(#b)E(?)^E${(l:2::0:)$((match[1]+1))}' ...
HappyFace's user avatar
  • 1,620
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
0 votes
2 answers
921 views

Alias when not first word: `G='|grep'` then `command G grep-string`

I find myself typing | grep and | less a lot, and was wondering if there was any way to be able to do something like: alias G='| grep -E' # egrep is deprecated alias L='| less' So I could do ...
Tom Hale's user avatar
  • 31.2k
2 votes
1 answer
321 views

Possible to make zsh up-arrow history search detect aliases?

I have git aliased to g. Sometimes I use g, and sometimes I don't. I might run git add file1 and later g add file2. When I want to add file1 again, I might type g add in the zsh prompt, and then ...
Riley Martine's user avatar
0 votes
2 answers
135 views

Using dir var in an alias?

I have a directory variable and function as follows: coding_dir="~/Documents/coding" function f() { cd $1 && ls -a ; } And I want to create an alias as follows: alias rnd="f $coding_dir/...
Kevin's user avatar
  • 139
2 votes
2 answers
285 views

Turn off one flag of command and infinite recursion

Since it overwrites my history when used in multiple terminals, I want to turn off the functionality fc -W. Unfortunately I have a habit of typing it often. I think it's not possible to make an alias,...
pfnuesel's user avatar
  • 5,927
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
1 vote
1 answer
863 views

How can bash aliases be configured to handle spaces in directory names? [duplicate]

The alias below works well in zsh when spaces in directory names are \ escaped, but bash doesn't handle them properly. What changes would be required to make them work with bash properly. dum() { ...
vfclists's user avatar
  • 7,619
1 vote
1 answer
940 views

Zsh suffix alias alternative in bash

In zsh I can open any file with a special suffix or extension like .log or .txt with a program with typing its file name only $ alias -s txt=nano $ word.txt That open the file word.txt with nano. ...
mostafa elmadany's user avatar
0 votes
1 answer
535 views

Using zsh alias to quickly clone a git repository with custom folder name

I want an alias shortcut to achieve the following: Clone a github repository with a custom folder name Open it in my fav text editor (atom) I currently use this inside ~/.zshrc: alias quickstart="...
hyang123's user avatar
  • 103
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
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
2 votes
1 answer
1k views

zsh alias with arguements

I have an alias for neovim-qt thus defined: gvim='nvim-qt --geometry 500x320 --' This allows me to call gvim foo.py ook.py and have a QT window running neovim with two tabs, one for each file. ...
Sardathrion - against SE abuse's user avatar
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

15 30 50 per page
1
4
5
6 7 8