Skip to main content

All Questions

Tagged with
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]:...
Sono's user avatar
  • 131
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 ...
ogbofjnr's user avatar
  • 125
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 ...
agentofuser's user avatar
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 ...
bitmaker's user avatar
  • 287
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 ...
Keltek's user avatar
  • 133
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:$'...
siryx's user avatar
  • 95
4 votes
1 answer
302 views

Tab complete global alias names not at the beginning of a line

I have a bunch of aliases like this alias -g foo=cmd1 alias -g faz=cmd2 alias -g fam=cmd3 At the shell (I'm using zsh) I want to be able to type echo fa<TAB> and be prompted for faz or fam ...
Justin Garrison's user avatar
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 "没有那个文件或目录" ...
roachsinai's user avatar
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 ...
m1well's user avatar
  • 101
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 ...
HappyFace's user avatar
  • 1,620
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 ...
Brian Hamill's user avatar
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
363 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
922 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
322 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
287 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
864 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
538 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
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
2 votes
1 answer
375 views

Why is a daily .zshrc reload required using an alias containing $(date -u +%Y%m%d)? [closed]

Each morning I run the following command that tails a log file created daily: ssh -t [email protected] tail -f development/abc/$(date -u +%Y%m%d).log This works just fine and each morning the log ...
little_bobby_tables's user avatar
0 votes
2 answers
501 views

ZSH function to edit a file based on an input at the cli

I need to set up a function in zsh that would edit a different file based on some input at the command line. I want to simplify my aliases so I don't have multiple aliases to do the same thing but ...
Ali Samii's user avatar
  • 441
2 votes
1 answer
806 views

alias ? not working in zsh

I was lead to believe that there were no differences between aliases in zsh and bash, however that appears to not be the case. I had an alias that would help me familiarize myself with the command ...
anAlias's user avatar
  • 21
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
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
2 votes
1 answer
122 views

Cancel an option used in aliased command?

Suppose for example, the following implementation of ll: alias ls="ls -F -G" # colourise and display dir,exec,etc. icons alias ll="ls -l -h -o" # long-list, use KB,MB,etc. sizes, no ...
OJFord's user avatar
  • 1,995
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
4 votes
1 answer
3k views

How to declare some aliases dynamically in zsh?

I would like to declare a few shortcut commands to switch between my various coding projects, so I have come up with the following script. projects=$(ls -d ~/Workspace/*/) prefix="/Users/myuser/...
le-doude's user avatar
  • 143
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
3 votes
1 answer
5k views

How to create an alias for two Git commands that use a parameter? [duplicate]

I regularly have to delete a local and remote Git branch. Therefore, I run the following commands: $ git branch -d feature-branch $ git push --delete origin feature-branch Since I mostly execute ...
JJD's user avatar
  • 587
3 votes
1 answer
41 views

On using $hash_array[$(global_alias)]

Identical code works on one system, fails on another: % zsh --version zsh 5.0.7 (x86_64-pc-linux-gnu) % typeset -A frobozz % alias -g foo='echo xyz' % frobozz[$(foo)]=9 % echo ${(kv)frobozz} xyz 9 % ...
kjo's user avatar
  • 15.6k
2 votes
2 answers
168 views

Forcing the expansion of a global alias in part of a word

I have a couple of scripts /tmp/foo/bar.sh and /tmp/foo/baz.sh, the look like this: # /tmp/foo/bar.sh alias -g __FILE__='${(%):-%x}' alias -g __DIR__='${${(%):-%x}%/*}' printf "sourcing %s\n" ...
kjo's user avatar
  • 15.6k
3 votes
2 answers
1k views

How to create hyphen alias for zsh?

I am using zsh and oh-my-zsh on Ubuntu. To change into the recent directory in the past there was an alias set to - which is the same as cd -. Somehow the alias disappeared at my machine. This might ...
JJD's user avatar
  • 587
1 vote
2 answers
2k views

How do you manage your bash/zsh Aliases?

How do you manage your bash/zsh Aliases? Is there a tool to do this more easily and less "think of an alias -> open .zshrc-sourced-file -> edit -> close, reload .zshrc -> use alias"?
wildeyes's user avatar
  • 1,155
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
0 votes
1 answer
554 views

zsh alias with linefeeds, commas and quotes

In my zshrc I have an alias like this: alias sl='screen -list' It fits my need (seeing what screens I have running), but the output is rather ugly: [pts/7]~% sl There are screens on: 32765....
tuvokki's user avatar
  • 103
0 votes
1 answer
4k views

zsh parse error after alias do=…

I have the following .zshrc file in my home directory: # modify the prompt to contain git branch name if applicable git_prompt_info() { current_branch=$(git current-branch 2> /dev/null) if [[ -...
Steven L.'s user avatar
  • 755
3 votes
1 answer
294 views

How can I use !! in zsh alias

I am trying to create an alias that builds upon my previous command. Say I run ag foo After looking at the list I want to be able to use those results in vim so I do vim -q<(!! --vimgrep) The ...
chrisortman's user avatar
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
1 vote
1 answer
826 views

alias -g '${1+"$@"}'='"$@"', what does it do?

Most makefile have this strange set of symbols '${1+"$@"}'. $@ is the makefile target filename. But why does, people try to use the complex symbol like '${1+"$@"}'?
user avatar
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
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
1 vote
2 answers
380 views

In zsh how to set an alias for `less` to get stderr output?

I find that there is a "global alias" for zsh. so when I set alias -g L='| less' command L will be replaced with command | less. But it seems that it cannot work with stderr output when I set ...
Hongxu Chen's user avatar
  • 5,858

15 30 50 per page