Sample Header Ad - 728x90

Unix & Linux Stack Exchange

Q&A for users of Linux, FreeBSD and other Unix-like operating systems

Latest Questions

1 votes
1 answers
449 views
evaluate terms in zsh without a command
I am using zsh with the [prezto](https://github.com/sorin-ionescu/prezto) configuration framework. I want to be able to type in terms like `1 + 2 * (3 / 4)` and get "2.5" out of it. Those terms could be recognized because they only consist of certain characters: `0123456789 +-*/()`. For everything m...
I am using zsh with the [prezto](https://github.com/sorin-ionescu/prezto) configuration framework. I want to be able to type in terms like 1 + 2 * (3 / 4) and get "2.5" out of it. Those terms could be recognized because they only consist of certain characters: 0123456789 +-*/(). For everything more complicated I am fine with opening a dedicated program (like a python shell). ## solutions that are not good enough 1. **Use a program**: I don't want to type python -c before my term or pipe it into bc. That's too much typing and I hope it can be done better. 2. **Use a function or an alias**: There are some [solutions](https://github.com/arzzen/calc.plugin.zsh) out there that allow to do these calculation when prefing it with a c or = or calc, like in = 1 + 2 * (3 / 4). That is nice but basically the same thing as point 1. 3. **Use another shell**: I know about [xonsh](https://xon.sh/) and I am sure there are other shells that can do that. But I like zsh and I don't want to change shells. ## what might work 4. **zsh plugin**: I could imagine a zsh-plugin that finds if a command matches a certain regex and then pipes it into python/bc/whatever. Somewhat similar to what the automatic cd thing does when you enter just the name of a directory. I don't know if this is possible though. I would love to hear some hints so I could write that. 5. **Intercept command not found**: Similar to 4. perhaps it is possible to intercept the behaviour of zsh when a command is not found. But again, I don't know how I would do that. 6. **alias all the numbers**: I guess you could write an alias for all the numbers so that they are commands that take the rest of the math-string as arguments. That might work, but seems pretty hacky. Also 'all the numbers' is quite a lot aliases, even when autogenerating the code for it. I would like to hear ideas on how to tackle this problem. I am not afraid of writing code, but I would prefere a clean solution over a hacky one.
Kaligule (113 rep)
Apr 29, 2022, 09:27 PM • Last activity: Apr 30, 2022, 01:52 PM
1 votes
2 answers
792 views
Git tracking dotfiles that are symlinked
I keep my dotfiles in a private git repo on bitbucket and this works great for the majority of my files (.vimrc, .tmux.conf etc) then I just set up symlinks from my home directory to my cloned gitrepo of dotfiles and everything works great. My problem is that I also use the prezto framework to manag...
I keep my dotfiles in a private git repo on bitbucket and this works great for the majority of my files (.vimrc, .tmux.conf etc) then I just set up symlinks from my home directory to my cloned gitrepo of dotfiles and everything works great. My problem is that I also use the prezto framework to manage zsh plugins. Prezto does something similar in that it stores all the .zprezto* config files in its own directory and symlinks to them from home. One of those files is the .zshrc which it stores in its own directory. It looks like this: .zlogin -> /home/jordan/.zprezto/runcoms/zlogin .zlogout -> /home/jordan/.zprezto/runcoms/zlogout .zpreztorc -> /home/jordan/.zprezto/runcoms/zpreztorc .zprofile -> /home/jordan/.zprezto/runcoms/zprofile .zshenv -> /home/jordan/.zprezto/runcoms/zshenv .zshrc -> /home/jordan/.zprezto/runcoms/zshrc How am I able to track my .zshrc file in my own git dotfiles directory without breaking prezto.
Jordan (243 rep)
Sep 13, 2016, 12:11 PM • Last activity: Mar 12, 2022, 05:03 PM
2 votes
1 answers
4355 views
Installing powerline fonts for zsh + Prezto theme
I am currently using Zsh + Prezto for my scripting shell configuration. I have been using the `sorin` theme but am a little dissatisfied with it. I'd like to switch to the [paradox](https://github.com/paradox460/prezto/blob/paradox/modules/prompt/functions/prompt_paradox_setup) theme! It is supposed...
I am currently using Zsh + Prezto for my scripting shell configuration. I have been using the sorin theme but am a little dissatisfied with it. I'd like to switch to the [paradox](https://github.com/paradox460/prezto/blob/paradox/modules/prompt/functions/prompt_paradox_setup) theme! It is supposed to look like this: > Blockquote I'm having some trouble doing that. When I switch to the theme, the symbols aren't able to load, so I get a prompt that looks like this: > Blockquote Notice the boxed question marks where there should be an edge border for the background or a branch symbol for the git branch. (Take a look at the paradox theme preview [here](http://mikebuss.com/2014/04/07/customizing-prezto/)) . I've seen [here](http://mikebuss.com/2014/04/07/customizing-prezto/) that I should install [Powerline patched fonts](https://github.com/powerline/fonts) for the symbols to load in correctly. However, as I'm somewhat unfamiliar with the process, I would love some help installing it into my Linux machine. In the [documentation](http://powerline.readthedocs.org/en/latest/installation/linux.html) , it notes I should install via pip. When I run pip install --user powerline-status, my prompt is still unable to display the symbols the way it should look. What else must I do, after running the installation, to display this prompt correctly? _I am using a MacBook Pro with El Capitan_
Cole Bittel (181 rep)
Oct 17, 2015, 09:26 PM • Last activity: Sep 19, 2021, 08:36 AM
0 votes
0 answers
718 views
Conditional zstyle format (color) for git branch name in zsh prompt (using prezto)
I am switching to zsh from bash and one thing that I'm used to is having the git branch name in my prompt coloured to reflect whether the branch is clean or not. So if my branch is `main` and it's clean, `main` appears in green, otherwise `main` appears in red. It feels like this should be simple to...
I am switching to zsh from bash and one thing that I'm used to is having the git branch name in my prompt coloured to reflect whether the branch is clean or not. So if my branch is main and it's clean, main appears in green, otherwise main appears in red. It feels like this should be simple to do, but I'm struggling to interpret the documentation . This is the default configuration in the theme I'm using: zstyle ':prezto:module:git:info:branch' format ' %%B%F{2}%b%f%%b' I can't find any references to being able to put conditional statements in the format strings. From the documentation, it looks like maybe there is a way to use subcontexts to achieve this: zstyle ':prezto:module:git:info:context:subcontext' format 'string' but there isn't any reference to what a subcontext actually is. As a fairly random guess about what a subcontext is, I tried this, but it makes no difference. Not surprising as I could find no reference to any subcontexts of branch in the code, but this at least semantically describes the result I am aiming for! zstyle ':prezto:module:git:info:branch' format ' %%B%F{2}%b%f%%b' zstyle ':prezto:module:git:info:branch:dirty' format ' %%B%F{1}%b%f%%b' The zstyle statements are made during the setup of the prompt, so there is no way to use conditional logic (i.e. if-else) to control which zstyle statement is run at that time based on a specific branch. What's the obvious way to handle this that I'm missing?
dpwr (109 rep)
Aug 16, 2021, 08:20 AM
1 votes
1 answers
2776 views
How to change the prezto and zsh theme prompt?
I installed yadr and prezto to style the zsh prompt. I'm using the **steeef** theme: How do I change the format of the prompt: from --> `taciano at asimov in` to --> `taciano@asimov` I've tried to modify and I couldn't. I can't find where to make this adjustment.
I installed yadr and prezto to style the zsh prompt. I'm using the **steeef** theme: How do I change the format of the prompt: from --> taciano at asimov in to --> taciano@asimov I've tried to modify and I couldn't. I can't find where to make this adjustment.
Taciano Morais Silva (113 rep)
Mar 14, 2021, 09:10 PM • Last activity: Mar 16, 2021, 12:49 PM
6 votes
4 answers
15407 views
Changing directory color with zsh + Prezto
I am using [Prezto](https://github.com/sorin-ionescu/prezto) + zsh as my shell. I would like to change the color of directories when I `ls` my directory. For instance, here is what I currently have: [![My crappy ls listing][1]][1] Obviously, this is no fun, as I'm hardly able to read my directories...
I am using [Prezto](https://github.com/sorin-ionescu/prezto) + zsh as my shell. I would like to change the color of directories when I ls my directory. For instance, here is what I currently have: My crappy ls listing Obviously, this is no fun, as I'm hardly able to read my directories because the blue is so dark. I'd like to change it to white or orange or something lighter. This dark blue is specific only to directories. Files show up in a nice white text. Where and what settings must I find to change this? ---------- Attempted solutions: I tried adding eval $(dircolors -p | sed -e 's/DIR 01;34/DIR 01;36/' | dircolors /dev/stdin) to my zshrc, but am getting this error now when loading my prompts: > Blockquote
Cole Bittel (181 rep)
Oct 16, 2015, 08:12 PM • Last activity: Jun 26, 2020, 04:46 PM
0 votes
0 answers
30 views
Stderr sometimes gets redirected to /dev/null
Sometimes when i am working in a shell i suddenly find out that standard error has been linked to /dev/null. If i open a new shell it is back to normal. I am using zsh with oh-my-zsh and prezto. I have looked over the rc files but i cannot find any reason why this should happen seemingly at random.
Sometimes when i am working in a shell i suddenly find out that standard error has been linked to /dev/null. If i open a new shell it is back to normal. I am using zsh with oh-my-zsh and prezto. I have looked over the rc files but i cannot find any reason why this should happen seemingly at random.
xvy. (1 rep)
May 18, 2020, 11:48 AM
0 votes
1 answers
841 views
Tmux always shows hostname instead of application running
A weird thing is happening. I have been trying to debug it for 2 days with no luck. Nothing relevant around forums as well. I have just set up my wife's machine because I need to work remotely. I have transferred all my set up from my own desktop to my wife's laptop so everything should work just fi...
A weird thing is happening. I have been trying to debug it for 2 days with no luck. Nothing relevant around forums as well. I have just set up my wife's machine because I need to work remotely. I have transferred all my set up from my own desktop to my wife's laptop so everything should work just fine. And they do except a small thing which I cannot find out why it's not working. My desktop runs MX Linux 18.3 and my wife's laptop runs MX Linux 19.1 Configuration: MX Linux 19.1, tmux, zsh, prezto, vim So the problem now. When I open my terminal under tmux, the status-right shows the hostname. This is all good. When I open VIM though, the status_right pane_title still shows the local hostname while my desktop shows that vim is running plus the full path of the file opened by vim. Same with any other app e.g. htop. My wife's laptop does not update the status-right pane_title while my desktop does. I don't have access to my desktop at the moment so I will only post images of how it looks on my wife's laptop. Any ideas? enter image description here enter image description here enter image description here
George B. (101 rep)
Mar 26, 2020, 09:41 AM • Last activity: Mar 26, 2020, 11:36 AM
6 votes
3 answers
15804 views
Remove zsh autocomplete suggestion
When I type cd l and hit tab, zsh autocompletes to cd lightdm/ this is not a directory that is available to me (in fact I've uninstalled lightdm). How do I stop this from happening? I have prezto installed. https://github.com/sorin-ionescu/prezto
When I type cd l and hit tab, zsh autocompletes to cd lightdm/ this is not a directory that is available to me (in fact I've uninstalled lightdm). How do I stop this from happening? I have prezto installed. https://github.com/sorin-ionescu/prezto
Bart Snapp (163 rep)
Sep 16, 2018, 01:06 AM • Last activity: Mar 30, 2019, 06:12 AM
0 votes
1 answers
67 views
mv command automatically running sometimes when opening a new prompt, throws error about renaming a `z` file
I'm using Prezto for zsh, and sometimes when I open a new prompt this command automatically runs: ```mv: rename /Users/myusername/.z.19504 to /Users/myusername/.z: No such file or directory ``` I do have the `z` package installed. Any idea why this is happening or how I can start to debug it?
I'm using Prezto for zsh, and sometimes when I open a new prompt this command automatically runs:
: rename /Users/myusername/.z.19504 to /Users/myusername/.z: No such file or directory
I do have the z package installed. Any idea why this is happening or how I can start to debug it?
maxedison (101 rep)
Aug 7, 2017, 03:25 PM • Last activity: Aug 15, 2017, 05:17 AM
9 votes
1 answers
17402 views
bash: rsync: command not found
I'm on OSX using iTerm (3) with [prezto](https://github.com/sorin-ionescu/prezto) as my zsh configuration framework. I've a strange error message when I use `rsync`: $ rsync -avz --exclude='.git' src/ remote:/dst bash: rsync: command not found rsync: connection unexpectedly closed (0 bytes received...
I'm on OSX using iTerm (3) with [prezto](https://github.com/sorin-ionescu/prezto) as my zsh configuration framework. I've a strange error message when I use rsync: $ rsync -avz --exclude='.git' src/ remote:/dst bash: rsync: command not found rsync: connection unexpectedly closed (0 bytes received so far) [sender] rsync error: error in rsync protocol data stream (code 12) at /BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-51/rsync/io.c(453) [sender=2.6.9] When I check the path to rsync I see: $ which rsync rsync: aliased to noglob rsync $ type -a rsync rsync is an alias for noglob rsync rsync is /usr/bin/rsync It seems that it's an alias declared by prezto that uses the noglob macro. I also tried to call the rsync command with /usr/bin/rsync but didn't help. Any idea what's wrong here??
bachr (483 rep)
Feb 17, 2017, 10:35 AM • Last activity: Feb 17, 2017, 10:44 AM
7 votes
3 answers
1523 views
What is causing `diff` to run `git diff`?
I'd like to use `diff` as described [here](http://lifehacker.com/compare-the-contents-of-two-folders-with-the-diff-comma-598872057) 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 Similarly when I try to _u...
I'd like to use diff as described [here](http://lifehacker.com/compare-the-contents-of-two-folders-with-the-diff-comma-598872057) 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 Similarly when I try to _use_ diff, I get git errors because -rq is supported in man diff but not by git diff: ~ ❯❯❯ diff -rq ~/ ~/Desktop fatal: invalid diff option/value: -rq I'm using [Prezto](https://github.com/sorin-ionescu/prezto) and [hub](https://github.com/github/hub) which both help with git productivity, but neither creates an alias that doesn't at _least_ start with g, as far as I can tell. I've run a few scripts like [this](https://unix.stackexchange.com/questions/176205/how-to-find-file-defining-an-alias) to try to find something that's defining diff to git diff but to no avail. How do I fix this/find what's causing it/override it? # Edit Ran type diff: diff is a shell function diff is /usr/bin/diff
Ben Saufley (173 rep)
Dec 11, 2015, 11:02 PM • Last activity: Feb 3, 2017, 09:29 PM
19 votes
1 answers
8709 views
zsh keeps sharing history even when shared history is disabled
I'm using zsh with prezto (on OSX and inside tmux, not sure if it matters), and from time to time history gets shared between multiple terminals. I already added unsetopt share_history and also unsetopt SHARE_HISTORY to the end of my .zpreztorc, but it keeps mixing up history. The output of setopt s...
I'm using zsh with prezto (on OSX and inside tmux, not sure if it matters), and from time to time history gets shared between multiple terminals. I already added unsetopt share_history and also unsetopt SHARE_HISTORY to the end of my .zpreztorc, but it keeps mixing up history. The output of setopt shows that "sharehistory" is still there! Even after adding unsetopt sharehistory.
amfcosta (365 rep)
Jul 11, 2016, 03:00 PM • Last activity: Jul 11, 2016, 11:05 PM
2 votes
2 answers
1245 views
Ctrl-Arrow does not work anymore after installing Prezto
I have this in my `.inputrc`: "\e[A": history-search-backward "\e[B": history-search-forward set show-all-if-ambiguous on set completion-ignore-case on # mappings for Ctrl-left-arrow and Ctrl-right-arrow for word moving "\eOc": forward-word "\eOd": backward-word "\e[1;5C": forward-word "\e[1;5D": ba...
I have this in my .inputrc: "\e[A": history-search-backward "\e[B": history-search-forward set show-all-if-ambiguous on set completion-ignore-case on # mappings for Ctrl-left-arrow and Ctrl-right-arrow for word moving "\eOc": forward-word "\eOd": backward-word "\e[1;5C": forward-word "\e[1;5D": backward-word "\e[5C": forward-word "\e[5D": backward-word "\e\e[C": forward-word "\e\e[D": backward-word Also, I didn't touch anything in .zprezto/modules/editor/init.zsh, where bindkey instructions are defined. However, when I press CtrlLeft or CtrlRight my terminal (URxvt) blinks and nothing happens. On the other hand, in XTerm it works. It appears to be a URxvt problem.
rubik (847 rep)
Feb 7, 2015, 01:15 PM • Last activity: Jun 8, 2016, 09:29 AM
1 votes
1 answers
1271 views
Can I selectively disable zsh completions?
I'm using prezto with `zsh`, and find it a little slow to launch a new shell. (N.B. I'm attempting to optimise on a fast-ish system, before moving my configuration to other, slower systems.) Benchmarking with `time zsh -i -c exit`: * 0.046: `bash`. * 0.080: `zsh` without prezto. * 0.092: `zsh` with...
I'm using prezto with zsh, and find it a little slow to launch a new shell. (N.B. I'm attempting to optimise on a fast-ish system, before moving my configuration to other, slower systems.) Benchmarking with time zsh -i -c exit: * 0.046: bash. * 0.080: zsh without prezto. * 0.092: zsh with prezto, but no modules loaded. * 0.138: zsh with prezto, and all "default" modules loaded, except for completion. * 0.308: zsh with prezto, and all "default" modules loaded. Firstly, zsh is 74% slower than bash to load. I could accept the further 73% slowdown (with prezto and all modules except completion loaded), but the 285% slowdown (with all modules) is a bit too much. Some of these completions are useful, so **is there a way to selectively disable some of these?** I've heard mention of this [elsewhere](https://tlvince.com/fixing-slow-zsh-command-completion) , although I'm not sure if this is only to improve tab-completion speed, or shell loading as well. (If I could selectively disable completion, this would allow me to profile and work out what was causing the slowdowns.)
Sparhawk (20499 rep)
Apr 22, 2016, 01:37 AM • Last activity: Apr 22, 2016, 02:33 AM
1 votes
0 answers
55 views
Is there a better to find out the script location which is part of a zprezto module?
I am writing a custom module to extend the [zprezto][1] framework for myself. The goal is to be able to start a tmux with proper configuration by name. Here is the code of the `init.zsh` of my custom module: SCRIPT=${0:A} export _MYTMUX_SDIR=`dirname $SCRIPT` function start_tmux { PROJECT_NAME=$1 tm...
I am writing a custom module to extend the zprezto framework for myself. The goal is to be able to start a tmux with proper configuration by name. Here is the code of the init.zsh of my custom module: SCRIPT=${0:A} export _MYTMUX_SDIR=dirname $SCRIPT function start_tmux { PROJECT_NAME=$1 tmux has-session -t $PROJECT_NAME 2>/dev/null if [ "$?" -eq 1 ] ; then echo "No Session found. Creating and configuring..." tmux new-session -d -s $PROJECT_NAME tmux source-file ${_MYTMUX_SDIR}/tmux-${PROJECT_NAME}.conf else echo "Session found. Connecting." fi tmux attach-session -t $PROJECT_NAME } function start_aws { start_tmux aws } function start_digitalocean { start_tmux digitalocean } I am forced to export a variable _MYTMUX_SDIR to keep track of the location of the script. It is needed because the tmux configuration files are colocated with the module init.zsh script. If I put this code inside the function body, it will give me the directory location wherein the function is called. **My question:** Is there a better way to find out the script location? I want to avoid putting variable in environment unnecessarily.
Anthony Kong (912 rep)
Feb 22, 2015, 03:05 AM • Last activity: Feb 22, 2015, 10:27 PM
Showing page 1 of 16 total questions