Tagged Questions
4
votes
2answers
42 views
Passing glob expressions to functions/scripts
The following script is supposed to concatenate multiple csv files in a path specified in the first argument into a single csv file specified in the second argument
#!/bin/zsh
set -x
set -v
...
0
votes
0answers
19 views
Getting “zsh: command not found: time” when running `time` in subshell
I installed ZSH (and Oh-My-ZSH) on a Ubuntu 12.10 64 bit machine a few days ago. I just tried to do:
time (time ls)
and got this error:
zsh: command not found: time
( time ls; ) 0.00s user 0.00s ...
0
votes
1answer
27 views
Weird behavior when sourcing .zshrc
I'm using zsh 5.0.2 (x86_64-apple-darwin12.3.0) on the latest MacOSX. If it makes any difference, I have also enabled oh-my-zsh.
The shell seems to be missing the .zshrc file when I want to source ...
3
votes
1answer
31 views
Ignore files for zsh's completion for SVN
I managed to configure zsh such that it does not suggest LaTeX temporary files when I use autocompletion for emacs by adding this line to my ~/.zshrc:
zstyle ':completion:*:*:emacs:*:*files' ...
2
votes
0answers
51 views
zsh: Echoing every statement?
I have an odd problem with zsh when I switch between shells in a particular way:
Option 1 (works well):
I start a zsh shell. I switch to tcsh with /bin/tcsh, and I switch back to zsh with /bin/zsh
...
-4
votes
1answer
116 views
zsh: Is it worth the switch from bash? Is it the time? [closed]
I have been a bash user for years now. However, I find that zsh is increasingly gaining momentum. I came up with the following questions:
Is zsh really becoming that popular? Will it compete with ...
2
votes
1answer
57 views
Why is `kill -s INT <zsh PID>` behaving differently from `Ctrl-C`?
Starting with:
% donothing () { echo $$; sleep 1000000 }
% donothing
47139
If at this point I hit Ctrl-C at the same terminal that is controlling the shell, then the function donothing does indeed ...
2
votes
1answer
74 views
dircolors on zsh: Unrecognized keywords: MULTIHARDLINK, RESET & CAPABILITY
I am trying to get the solarized color theme to work in my terminal. I read the instructions here but I get the following dircolors error:
dircolors: `/home/avazquez/.dircolors_zsh':90: unrecognized ...
2
votes
3answers
89 views
Treatment of backslashes across shells
How do echo and printf treat backslashes in zsh, bash and other shells?
Under zsh I get the following behavior:
$ echo "foo\bar\baz"
foaaz
$ echo "foo\\bar\\baz"
foaaz
$ echo 'foo\bar\baz'
foaaz
$ ...
6
votes
2answers
104 views
When is double-quoting necessary?
The old advice used to be to double-quote any expression involving a $VARIABLE, at least if one wanted it to be interpreted by the shell as one single item, otherwise, any spaces in the content of ...
4
votes
1answer
84 views
ZSH: What's the difference between `.` and `source`?
I used to think that the built-ins . and source are equivalent. This question agrees with me when it comes to bash. However I encountered the following using zsh:
desktop➜ ~/pst . env
...
1
vote
2answers
82 views
Different shells for interactive and non-interactive work
Due to constraints at my workplace, the default shell for every user is tcsh, and I am required to use tcsh as my non-interactive shell (i.e. we do most of the environment configuration across ...
1
vote
0answers
18 views
Make zkbd ignore $DISPLAY
Is it possible to make zkbd ignore $DISPLAY variable? I have set up when I log in to different X sessions and it is annoying if suddenly I need to reenter/copy configuration (and I have no idea why ...
1
vote
2answers
112 views
OS X setting environment variables
I have OSX 10.8.2 with ZSH as my shell and iTerm as a terminal (don't know if the last thing is relevant). I have to mention that I'm relatively new to OSX.
I'm trying to set up some environment ...
1
vote
1answer
46 views
How to make ZSH tab completion work with two tabs
I saw a question like this on here, but the answer didn't work for me. I'm trying to set up tab completion and I want it that if I have two files fileA and fileB and I type fil<tab> it first ...
0
votes
2answers
102 views
Comparison of shells? [closed]
Do shells have any actual advantages or disadvantages? They can all run any binary, they all support pipes and > (output to file). Why would one choose bash over sh, or sh over ksh, etc? Why does ...
4
votes
3answers
109 views
Can any shell do argument-level interactive search?
Sometimes I need to reuse certain long arguments like paths.
If I use history search (CTRL+R), I may find some command that contains the path, but I still need to delete anything else in the old ...
0
votes
2answers
128 views
Proper place to put shell prompt(PS1) when use sh/bash/zsh together
I'm using dash(sh) or bash or zsh. If possible, I would prefer to put in common place.
I want to put proper PS1 settings when I interactive with shell, so these situation should be considered
login ...
4
votes
2answers
252 views
Bash function not working in Zsh
I have been slowly migrating from Bash to Zsh and have got to the point where everything I have moved across is working well, with one exception.
I have a couple of functions in my .bashrc that I use ...
-1
votes
1answer
62 views
Config File Sequence for ZSH?
I know there is an elaborate sequence of config files that BASH reads sequentially (or alternatively skips if a particular one is present), however I have for the most part adopted ZSH as my default ...
1
vote
4answers
106 views
Zsh: dirs in reverse order
I am a bit confused about how dirs works. The documentation says:
dirs
With no arguments, print the contents of the directory stack.
Directories are added to this stack with the pushd ...
3
votes
5answers
537 views
Output multiple files from a single grep?
I'm not very experienced in shell scripting, but I'm trying to understand how to grep for a pattern and for each file where there is a match write a file to disk that contains the matched line from ...
3
votes
1answer
103 views
How to expand a substring of a command?
I would like to know what a command would look like if I entered a substring of this command. I'm not interested in the result, but in the history expansion.
The purpose of this is to show in an ...
3
votes
3answers
347 views
Using OR patterns in shell wildcards
Contents of my dir are
$ ls -lrt
total 0
-rw-r--r-- 1 user1 admin 19 Oct 8 12:31 night.txt
-rw-r--r-- 1 user1 admin 19 Oct 8 12:31 noon.txt
-rw-r--r-- 1 user1 admin 38 Oct 8 12:31 day.txt
I ...
0
votes
0answers
67 views
/long/path/to/{multiple, files} syntax? [duplicate]
Possible Duplicate:
Quick way to include a directory path when calling mv?
Is there any way in bash to type a path once, and then reference several files at once?
Here's what I do now:
...
5
votes
4answers
478 views
List X random files from a directory
Is there a way to list a set of say, 30 random files from a directory using standard Linux commands? (in zsh)
The top answer described here does not work for me (sort does not recognize the option ...
2
votes
2answers
183 views
Piping paths with different types of quotes for slash substitution
I would like to use sed to convert a path with backslashes to the same path with forward slashes:
E.g.
I would like to pipe \\path\to\file\ and obtain /path/to/file
None of the following commands ...
0
votes
1answer
964 views
Script failing with “command not found: ^M”
When I try to run the following script in zsh, via the command /bin/zsh ~/.set_color_scheme.sh I get the following error:
command not found: ^M
The script has u+x permissions and it used to work on ...
0
votes
2answers
134 views
Installing a shell (e.g. zsh) without being system admistrator [duplicate]
Possible Duplicate:
how can I use bash as my login shell when my sysadmin refuses to let me change it
Say I have rwx permissions to a directory (my home directory). Can I install a shell ...
5
votes
1answer
1k views
Executing a script in zsh - file permissions
I'm confused about execute file permissions not behaving as I expect. Probably because my expectations are wrong. Anyway:
I have a script file, for simplicity is just called s, located in ~/bin. For ...
1
vote
1answer
371 views
Do shells support recursion?
I'm trying to write recursive functions in my shell scripts.
Consider the following code:
function printA {
if [[ "$1" = 0 ]]; then
return
else
echo "a$(printA $(("$1" - 1)))"
...
2
votes
1answer
65 views
Restoring an option at the end of a function in zsh
I'm writing a zsh shell function (as opposed to a script) where I would really like the extended_glob option to be enabled. But since the function runs in the caller's context, I don't want to clobber ...
6
votes
1answer
168 views
Ksh features incorporated into Zsh?
I have been a user of Bash for some time. I want to learn at least one other shell now, so I have been picking up the Korn Shell. However, it doesn't look like Ksh has had major updates for almost ...
4
votes
1answer
1k views
Running chsh does not change shell
I want to change my shell from bash to zsh.
I have tried running the following while logged in as user zol:
$ chsh -s /bin/zsh
$ sudo chsh -s /bin/zsh zol
$ su -c 'chsh -s /bin/zsh zol'
# The above ...
1
vote
2answers
294 views
Weird zsh grep -P behaviour
I connect to server with PuTTY from Windows.
I have a long yet not touched (I suppose) by hands of local admin config:
$ cat /opt/jira/.subversion/config
...
### must be enabled, which is ...
2
votes
3answers
6k views
Change font in echo command
Is it possible to change the font attributes of the output of echo in either zsh or bash?
What I would like is something akin to:
echo -n "This is the font: normal "
echo -n $font=italic "italic,"
...
1
vote
1answer
92 views
Load command parameters from upper level file
I've come across an interesting problem that I have not yet been able to solve satisfyingly.
Consider a note taking command that takes two arguments:
note $project $note
That simply files the ...
3
votes
2answers
413 views
Zsh — more intelligent autocorrection
Is it possible to make Zsh stop trying to correct arguments that are not meant to be files with files from the current directory without turning off correction completely or limiting it to setopt ...
3
votes
4answers
333 views
Get input from editor (vim/nano/emacs/textmate?)
I was just curious if there's a way to get input not from StdIn but from $EDITOR - be it vim, nano, emacs or even a non-command-line-editor (MacVim/TextMate). What are the ...
2
votes
2answers
209 views
Shell Prompt Customization?
I have used oh_my_zsh (and tinkered with bash_it) on multiple systems and have generally been happy with it, though I hate it's auto-correction feature and generally turn it off.
My usual shell is ...
8
votes
2answers
2k views
In zsh how can I list all the environment variables?
I want to get a list of all environment variables (shell variables? exported variables?) and their values at a given time, in zsh.
What is the proper way to do this?
6
votes
2answers
929 views
List elements with spaces in zsh
I've been studying zsh scripting for all of 2 hours at this point and I've hit a wall. I want to go through a list of files that may have spaces in them. I'm open to completely different approaches ...
1
vote
1answer
137 views
How to access user's fpath as opposed to system's fpath with a script?
test.zsh:
#!/usr/bin/env zsh
for f in ${fpath}; do
echo ${f}
done
outputs:
...
6
votes
3answers
3k views
How do I reverse a for loop?
How do I properly do a for loop in reverse order?
for f in /var/logs/foo*.log; do
bar "$f"
done
I need a solution that doesn't break for funky characters in the file names.
3
votes
2answers
90 views
Executables show with character * next to their name in output of ls
I noticed that when I list my executables with ls on my Z shell they show up with a character * next to their name (e.g. see the file in red .test_color_scheme)
What is causing ...
6
votes
2answers
560 views
What is word splitting? Why is it important in shell programming?
I'm getting confused about the role word splitting plays in zsh. I have not been exposed to this concept when programming in C, Python or MATLAB, and this has triggered my interest of why word ...
3
votes
1answer
1k views
Changing the default shell without chsh or administrator priviledges
I saw the following snippet in this thread: How to change from csh to bash as default shell
sleep 2
if (-x /usr/local/bin/bash) then
exec /bin/sh -c '. ~/.profile; exec /usr/local/bin/bash'
endif
...
5
votes
2answers
760 views
Pasting from clipboard to vi-enabled zsh or bash shell
I'd like to be able to paste from the system clipboard (or text selection) into my "vi-like" shell prompt using the keyboard. I normally use zsh and sometimes bash. In both cases, I have the shell set ...
3
votes
3answers
377 views
What does : ${param:=value} mean?
I read the following in A User's Guide to the Z-Shell:
A synonym for ‘true’ is ‘:’; it’s often used in this form to give
arguments which have side effects but which shouldn’t be used —
...
1
vote
1answer
103 views
Delete zsh auto completion suggestion
When I use tab-completion in zsh, the shell suggests me files and I discover that I'm in the wrong directory. How can I just delete the suggestion instead of backspace'ing it?
