Questions tagged [zsh]
The zsh tag has no usage guidance.
70
questions
68
votes
10
answers
18k
views
Unique Features of bash compared to zsh
I have been a zsh user for quite some time (before that tcsh and before that csh). I am quite happy with it, but was wondering if there are any compelling features of bash that do not exist in zsh. ...
36
votes
8
answers
24k
views
Is there any reason to use bash over zsh? [closed]
I'm curious about why one would want to run bash instead of zsh. I mean zsh is fully backwards-compatible with bash. Don't get me wrong: I don't dislike bash or anything. I just genuinely want to ...
31
votes
2
answers
13k
views
How do I make zsh completion act more like bash completion?
I'm a recent convert from bash to zsh (which I'm using "oh my zsh" with), but one thing annoys me:
When I hit the tab key, the first autocompletion is filled out automatically, and you need to cycle ...
22
votes
2
answers
21k
views
ZSH not sourcing zprofile
I'm running zsh 5.1.1 on Ubuntu 16.04. It seems that ~/.zprofile isn't sourced at login nor new terminal. ~/.zshrc is sourced however.
I am running oh-my-zsh.
Any ideas on why this is or how I can ...
21
votes
4
answers
18k
views
How to edit command completion for ssh on zsh?
I'd like to set up command completion on zsh to display host names after I type
ssh [TAB]
taking the names out of my .ssh/config file (and preferably from known_hosts and /etc/hosts and anywhere ...
18
votes
4
answers
19k
views
How to delete empty source directories when moving folders with rsync?
rsync can be coaxed into moving folders very similarly and superiorly to traditional mv with the following options:
rsync -axvvES --remove-source-files source_directory /destination/
However one ...
16
votes
4
answers
29k
views
Copy a range of files in command line (ZSH/BASH)
I have a list of files with consecutive numbers as suffixes. I would like to copy only a range of these files. How can I specify a range as part of my cp command.
$ls
P1080272.JPG* P1080273.JPG* ...
16
votes
1
answer
33k
views
How to change default shell in FreeBSD?
The default shell in FreeBSD is sh and I really can't stand it: autocomplete is very limited, and rehash commands kill me. I feel like a one armed and one legged man...
How can I change the shell ...
11
votes
4
answers
1k
views
Keyboard shortcut to store typed command and clean the line
You know the situation: You are halfway through typing a long command (for example a commit message) and realize that you have forgotten to execute some prerequisite command that can not be added with ...
9
votes
2
answers
17k
views
How to set the default shell when chsh is not present
I've a Synology DS412+ NAS box running Busybox, which has a default shell of ash. Previously, ipkg install optware-devel was run and it installed bash and set it as the default shell. Running ipkg ...
9
votes
3
answers
1k
views
Excluding Environment Variables from ZSH Autocomplete
Quick example:
~ $ wor<TAB>
~ $ WORDCHARS= ...
9
votes
3
answers
7k
views
ls gives me "illegal option"
I recently installed zsh and now whenever I ls or ls -l or ls anything I get "illegal option". Not sure where to start looking to fix this.
8
votes
3
answers
20k
views
How can I open a file whose name starts with "-"?
I am running Ubuntu, and would like to open a file whose file name starts with "-"(minus). When I try to open the file with pico or vim, the command thinks that the "-" sign is an option for the ...
6
votes
2
answers
8k
views
Removing history or line numbers from ZSH history file
For some reason I get these odd line numbers or history numbers of some sort into my ~/.zsh_history file like so:
: 1266694881:0;rake db:migrate
I'd rather not have to resort to regexing out the ...
6
votes
2
answers
5k
views
Unable to understand the benefit of Zsh's autopushd
I have in .zshrc
setopt autopushd
It makes cd acts like pushd.
This means that we have no stack at all.
When I have used it, I have not used stack at all, since it removes stack from me.
I am not ...
5
votes
2
answers
7k
views
Command 'getent'
Part 1
Is getent supposed to be an executable?
In my zsh setup, I can see getent is actually defined as a function
$ which getent
getent () {
if [[ $2 = <-> ]]
then
grep ":$...
5
votes
1
answer
747
views
Looking for zsh completion file for osX native commands
I've been digging deep into what actually comes with osX in /usr/bin and especially /usr/libexec.
Quite good stuff really, although the command syntax is a bit.. odd.
Let me direct the curious to ...
4
votes
1
answer
15k
views
zsh colored files directories
I have a host for my VM, when it had a fresh install of Ubuntu the bash shell had colored directories and files.
How do I duplicate this with ZSH, i've customized my PS1 but I want to customize the ...
4
votes
2
answers
3k
views
How can I put the last zsh command in history into a clipboard?
It often happens to me, that I just used a command and I need to copy/paste it either to a different terminal window/IM or whatever.
On a Mac, I can use the pbcopy command to get something in ...
4
votes
4
answers
1k
views
How can I add a word to each element of the array in Zsh?
I did in Zsh:
array={geometry, analysis, topology, graph theory, calculus}
echo $array
and then I wanted to add word "math:" to each element like" math:calculus":
while (( i++ < 10)); { echo ...
4
votes
1
answer
894
views
zsh autocompletes folders that don't exist
Just started using zsh with oh-my-zsh, and I noticed something odd when autocompleting with cd.
Suppose I have a folder:
my_folder/
subfolder/
another_subfolder/
file.txt
When I used ...
4
votes
2
answers
2k
views
remote ZSH and moving to beginning of line gives ^A print
do remote ssh connection in my tmux terminal (zsh) and remote shell is also zSH.
[devops@postgres-prod]~% vi /var/lib/pgsql/9.6/etc/postgresql.conf^A0A^A^A^E^A
So it doesn't react on Ctrl+A, Ctrl+E
3
votes
2
answers
3k
views
ZSH `--color=auto` doesn't work
For some reason when I execute the following:
ls --color=auto
Results with:
ls: illegal option -- -
usage: ls [-ABCFGHLOPRSTUWabcdefghiklmnopqrstuwx1] [file ...]
Not sure why this is happening, I'...
3
votes
1
answer
139
views
In bash, how do I get possible completions to disappear afterwards?
In bash, when I hit tab and the completion is ambiguous, it appears like this on my screen:
chris@host / $ cd fo
foo/ for/ foz/
chris@host / $ cd fo
I then continue typing, but I get to another ...
3
votes
1
answer
242
views
How do you avoid the extra carriage return when you use Zsh history expansion? [closed]
I'm a recent convert to zsh (from bash).
In zsh, as in bash, there is the history expansion feature.
For example, you can do:
git blame somefile.cc
vim !$
Here, vim !$ is same as typing out the ...
2
votes
2
answers
616
views
Unable to make Zsh not to suggest a fix for an alias
I have an alias for
alias tdA='todo -a'
I get the following in Zsh
tdA
zsh: correct 'tdA' to 'tda' [nyae]?
How can you make Zsh not to suggest a fix for an alias?
2
votes
3
answers
3k
views
In zsh, how do you redirect stderr to /dev/null within a for or foreach loop?
I am trying to accomplish something that is easy in bash: look for files in a folder and source them if they exist (and do not output if no files exist).
In bourne shells this is how to do it:
if [...
2
votes
4
answers
3k
views
SSH connection closes as shell fails to load
I have FreeBSd running with OpenSSH. I set up everything and the connection via SSH worked perfectly. Then I decided to get rid of some not used ports and I obviously uninstalled one that was used by ...
2
votes
1
answer
1k
views
Get on zsh the same result you get when executing `type -t` on bash?
I have shell script that uses type -t, but since apparently it was originally written for bash and on this machine I on zsh, it's not working.
I see bash docs that type -t does:
If the -t option ...
2
votes
2
answers
609
views
Null a file in zsh
In bash i can truncate a file with:
$ > file
However the same command in zsh hangs.
Is it possible to configure zsh to emulate bash when truncating files?
2
votes
3
answers
71
views
Anybody knows if there is a counterpart for CTR+w , that deletes immediate words after cursor
I mean when the cursor is on the left side of the words ,I would like to remove the words on the immediate right side of it . CTR+k remove everything on the right side, i only want one word to be ...
2
votes
3
answers
3k
views
Change the shell for cron job
I have a zsh script that I would like to run via anacron every week.
It runs fine from an interactive bash shell, but when run by anacron, I am getting command not found errors and it looks like it ...
2
votes
2
answers
3k
views
How to stop the shell interpolating?
I'm writing a bit of Ruby for use on the command line, but the shell is interfering too much - is there a way to turn off interpolation for the entire line? I know I can escape certain characters, but ...
2
votes
4
answers
798
views
Running an application in background
I have a web app on a freebsd server. An app is a single executable file, with a built-in webserver. My default shell is zsh.
When I'm running it as "./my_website &" and close a connection, it ...
2
votes
1
answer
391
views
mirror STDOUT and STDERR to file by default
How I can accomplish STDOUT to be to logged in a file (appending), but preserving the flow (leave STDOUT to STDOUT) ?
STDOUT should work transparently, but should be logged also into a file, without ...
1
vote
1
answer
209
views
Toggle Foreground Process
Ctrl-z suspends the foreground process, but when there is nothing in the foreground it has no effect. I want to overload ctrl-z so when there is nothing in the foreground it brings the most recently ...
1
vote
1
answer
416
views
Shell script prevent switching to other shell or escape from it
If in my automation script, I need to do something like install oh-my-zsh, I will have a .sh script like this:
#!/bin/sh
runuser -l user -c 'sh -c "$(curl -fsSL https://raw.githubusercontent.com/...
1
vote
2
answers
1k
views
why won't bash display the results of a 'bind -p' command?
bash refuses to give me the output of 'bind -p' when I pass it in with the -c switch:
bash -c 'bind -p'
but it works to type
bind -p
directly at the bash prompt, and it works to type something ...
1
vote
2
answers
229
views
Add "sudo" to the last command line in bash
I run a command, then realize it should have been run with sudo.
In zsh I have a function so that I can hit a ^x^x and it will grab the previous line from the history and prepend sudo to it, so I ...
1
vote
2
answers
982
views
zsh printf quote bug
does anyone have any idea why am I getting hit by this bug in zsh since forever?
It's like a string formatting bug of some sorts:
~% printf "%s\n" foo
" foo)foo
Basically anything that has double ...
1
vote
1
answer
85
views
zsh completion ( compctl ) does not trig for command names containing dashes
I've used zsh compctl since forever (late 90s or early 00s) but strangly never run into this before.
I realized today when I intended to make some compctl config for update-alternatives that my ...
1
vote
1
answer
285
views
The ssh-agent process is not visible to the user who created it but is visible to root
I have adopted the following snippet from Visual Studio Code's documentaion to create an ssh-agent on login:
if [ -z "$SSH_AUTH_SOCK" ]; then
# Check for a currently running instance of ...
1
vote
1
answer
682
views
zsh, zmv mass rename sub directories nothing happening on large volume of directories
I've set
autoload -U zmv
alias mmv='noglob zmv -W'
When on sample data (~20 folders with subfolders) I run
mmv images/**/advert images/**/notice
it just works as expected.
But if I run same ...
1
vote
1
answer
201
views
Enable 8th bit as Meta in zsh without a warning
In my quest to configure my shell to work exactly how I want it with respect to the alt/meta key I am having some trouble. Recently I added "bindkey -m" to my .zshrc and now whenever I start a zsh ...
1
vote
0
answers
3k
views
Netcat on MacOS failing with simple commands
I'n trying to follow a tutorial here.
As an example we can say that we need a friend of ours to help us with something on our work system(Windows). To be able to receive a connection from us first ...
1
vote
0
answers
229
views
debugging zsh completion method
I am trying to debug a completion method. This method is supposed to present with all the directories within these three folders. I verified that compinit is loading it correctly. tried tracing and ...
1
vote
1
answer
417
views
How to stop CentOS 7 fresh install to stop `clear` from running on exit from ssh session?
I'm finding that upon exit from an ssh session on a CentOS 7 server, it clears the screen each time. I suspect that there's a setting in /etc for the environment that is doing this.
Any ideas of ...
1
vote
1
answer
2k
views
Trouble installing ZSH
I did the following:
yum install zsh
Then
chsh eduar
New shell [/bin/bash]: /bin/zsh
When I type:
curl -L http://install.ohmyz.sh | sh
I got this:
You already have Oh My Zsh ...
1
vote
1
answer
370
views
zsh extended globbing to create sub directories
% zsh --version
zsh 5.0.2 (x86_64-apple-darwin13.0)
% ls -l
bootstrap/ local_folder/ ssh_confs/ zsh_confs/
I am trying to create a sub directory called "files" inside all the directories in ...
1
vote
0
answers
269
views
Trouble with name resolution when using programs like `gem` in shell
I have trouble with name resolution when using programs like gem in my shell within my office environment.
Whenever a program needs to connect to a remote host, it fails to resolve the domain name, ...