Questions tagged [zsh]
68 questions
5
votes
2 answers
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 ":$2:[^:]*$" /etc/$1
else
grep "^$2:" /etc/$1
…

Anthony Kong
- 3,288
- 11
- 57
- 96
5
votes
1 answer
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 the command that made me think of…

chiggsy
- 1,586
- 1
- 15
- 20
4
votes
2 answers
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

DmitrySemenov
- 835
- 2
- 15
- 27
4
votes
2 answers
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 clipboard, but I'm not sure how should I get to the…

Jakub Arnold
- 1,744
- 10
- 26
- 33
4
votes
1 answer
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 bash, I could type:
$ cd p
And nothing would…

seth
- 145
- 5
4
votes
4 answers
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 math:$array[i] }
But it does not work? Why?
Zsh
4
votes
1 answer
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 color of directories as well... how do I do this?

JP Silvashy
- 1,447
- 6
- 24
- 30
3
votes
1 answer
How do you avoid the extra carriage return when you use Zsh history expansion?
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 full file name vim somefile.cc.
However, in zsh, after…

Zack Xu
- 133
- 3
3
votes
2 answers
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'm wondering if anyone else has had the same issue.

JP Silvashy
- 1,447
- 6
- 24
- 30
2
votes
1 answer
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 is used, type prints a single word which is one of…

yivi
- 163
- 1
- 2
- 11
2
votes
4 answers
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 terminates. However, when I switch to bash by…

Dari
- 121
- 2
2
votes
3 answers
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 is ignoring the shebang line.
The actual…

Ryan Ahearn
- 317
- 2
- 10
2
votes
2 answers
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?

Zlemini
- 151
- 6
2
votes
3 answers
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 [ -d /etc/profile.d ]; then
for f in `ls -1…

chrishiestand
- 974
- 12
- 23
2
votes
1 answer
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 completion:
chris@host / $ cd fo
foo/ for/…

Chris Mounce
- 23
- 2