Skip to main content

All Questions

Tagged with
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. ...
2 votes
1 answer
956 views

Aliases don't work in interactive zsh

I have a curious problem where my aliases are listed when I type alias, but they are not executable. Here, I try to alias d to date: % which alias alias: shell built-in command % alias d=/usr/bin/...
0 votes
1 answer
366 views

Having sudo and non-sudo parts in an alias - why does it not work with >>?

I was trying to use an alias which should run two commands, where the first is fine to be run with normal user privileges and the second one needs sudo privileges. alias hosts-get="scp [email protected]:...
0 votes
1 answer
412 views

How to supress aliases errors in zsh?

I want to have single list of aliases that I source to my .zshrc on all my computers and sync. But on one computer I have docker installed, and on another I don't. And every time I open terminal get ...
3 votes
1 answer
4k views

How to pipe into zsh with alias expansion?

I'm trying to run a line from history by piping it into zsh with: cat ~/.zsh_history | cut -d ';' -f 2 | sk --tac | zsh This works if the line I pick interactively with sk is a command that is ...
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 ...
0 votes
1 answer
111 views

How can I automatically fix cd typos?

I often type quickly and will mistype cd ../ as c d../, and for some reason on most of the Linux servers I work on that gives about a 4-5 second delay before telling me it was wrong. Is there a way to ...
1 vote
1 answer
443 views

Setting up aliases for a history expansion pattern

similar to the existing $_ which I learned stands for !-1:$, I would like to create aliases for $__, $___ and so on which refer to the 2nd or 3rd -last command. I have tried adding alias "$__"='!-2:$'...
2 votes
1 answer
658 views

Expand alias in ZSH history

I have the following alias in my zshrc alias nif='nvim $(rg --files | fzf -m || echo +qa)' Essentially, I use rg (ripgrep) to show all the files in the current directory and in sub directories. This ...
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 ...
0 votes
2 answers
2k views

How to get file path which was selected and make copy in dolphin KDE and paste on zsh?

➜ ~ cat .zshrc | grep xclip alias c="xclip -selection c" alias -g v='"$(xclip -selection c -o)"' ➜ ~ v zsh: 没有那���文件或目录: file:///home/roach/Downloads/pure.png ➜ ~ The Chinese words "没有那个文件或目录" ...
0 votes
1 answer
333 views

What is the best way for storing and versioning his aliases/functions/symlinks?

actually I have these lines (exemplary) in my .zshrc file: . ${TOOLS_HOME}/cli/.cli_base . ${TOOLS_HOME}/cli/.cli_functions . ${TOOLS_HOME}/cli/.cli_symlinks This works fine so far. My only problem ...
0 votes
2 answers
723 views

How do I put an argument into the BROWSER variable?

I like to be able to do export BROWSER="lynx -cfg=~/.lynx.cfg". I tried this directly, and I also tried setting an alias alias lynx="lynx -cfg=~/.lynx.cfg", but these didn't work. (Meaning that tools ...
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 -...
3 votes
1 answer
2k views

Using heredoc in zsh aliases

I would like to use heredoc in a zsh alias, for example: alias runthing="cd ~; date << HERE date HERE" However every time I run this alias, the shell acts as if I have not terminated the ...

15 30 50 per page
1
4
5
6 7 8