You are not logged in.

#1 2017-07-07 06:47:03

DarrenHaynes
Member
Registered: 2017-01-25
Posts: 22

[SOLVED] i3wm layout urxvt vim open buffers recursively issue

Aloha - I am trying to figure out an issue I have when trying to open an i3wm layout template that swallows urxvt, and passes urxvt a command to open filetypes in vim recursively.

First up my saved i3wm layouts are working fine. And I have a bash script that opens a layout and swallows urxvt into the layouts just fine. So far so good. Where I am stuck is when I try to pass

vim **/*.html

to urxvt.

Here is the script:

#!/bin/bash

cd ~/freeCodeCamp/local-weather-app
i3-msg "workspace Project; append_layout /home/darren/i3-project-manager/templates/codepen.json"

(urxvt -e vim **/*.html &)
sleep 0.1

python ~/Py_Scripts/xr_random_colors.py
(urxvt -e vim **/*.js &)
sleep 0.1

python ~/Py_Scripts/xr_random_colors.py
(urxvt &)
sleep 0.1

python ~/Py_Scripts/xr_random_colors.py
(urxvt -e vim **/*.css &)

Here is the tree structure of the directory ~/freeCodeCamp/local-weather-app

├── css
│   ├── html_in_css.html
│   └── style.css
├── index.html
├── js
│   └── index.js
└── test.js

So if I am in the directory ~/freeCodeCamp/local-weather-app in a urxvt terminal in an i3wm window - not using a layout template, but just normally opening a window - and I then type into urxvt

vim **/*.html

it will open `index.html` and `/css/html_in_css.html` files as buffers in vim, as one would expect. However this same code in the bash script above does not produce the same result. Vim does not open the `index.html` file, only the recursive file `html_in_css.html`. I don't know what's up with that?

Also if I remove `/css/html_in_css.html` file (which should not be there anyway, its just for testing purposes) then I get bigger problems. The `index.html` file is still not found by vim, but vim does open an empty file with a bizarre title

*.html (**)

. That file also crashes and just locks up vim. You can see what I mean in this image:
html.png
On the left hand side is the html window.

I know this maybe a too specific case to figure out, but I am no expert, and hoping someone may have an idea. I did post this issue on the i3wm forum, but got no responce there.

Last edited by DarrenHaynes (2017-07-07 23:16:56)

Offline

#2 2017-07-07 10:18:20

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: [SOLVED] i3wm layout urxvt vim open buffers recursively issue

You need to

shopt -s globstar

in your script. Enabling this option gives the double asterisk its special meaning. It's off by default, but often enabled for interactive shells.

With globstar off, you get all .html files in any immediate subdirectories (same as */*.html), excluding the index.html in the current directory. After removing css/html_in_css.html, there are no matches and the unusual filename '**/*.html' is passed to vim (this behavior can be changed with nullglob and failglob in bash). Your vim screenshot doesn't show the actual error, only the follow-up message, but it's probably complaining because the directory '**' doesn't exist.

Offline

#3 2017-07-07 23:15:39

DarrenHaynes
Member
Registered: 2017-01-25
Posts: 22

Re: [SOLVED] i3wm layout urxvt vim open buffers recursively issue

Thank you, that was it.

It was the last little thing tripping me up in the little python and bash script I created to open my projects the way I like them. I just added some additional logic to check if the file types exist at all as that will through an error also. I simply have the bash script open an empty vim buffer in that case. Aside from that adding

shopt -s globstar

took care of things.

Offline

#4 2017-07-08 08:30:39

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: [SOLVED] i3wm layout urxvt vim open buffers recursively issue

DarrenHaynes wrote:

I just added some additional logic to check if the file types exist at all as that will through an error also. I simply have the bash script open an empty vim buffer in that case.

It sounds like that additional logic could be removed if you go with

shopt -s globstar nullglob

Offline

#5 2017-07-08 16:11:45

DarrenHaynes
Member
Registered: 2017-01-25
Posts: 22

Re: [SOLVED] i3wm layout urxvt vim open buffers recursively issue

Thanks again - that shortened the script quite a bit - no more IF statements smile

Offline

Board footer

Powered by FluxBB