vim-rest-console displays JSON in a single line - json

I've found out about vim-rest-console, but after installed and run a test, I noticed the JSON it outputs is only in one line, without any indentation. This is horrible and I'd like to know if there is a way to solve this. I am using NeoVim on Xubuntu 16.04 LTS.

To fix the json indentation in Vim, put the following command to your .vimrc
nmap =j :%!python -m json.tool<CR>
and launch it via the =j command (or remap to different shortcut).

Related

git log --pretty=format windows strange behavior

I reduce the problem to its lowest terms.
Under linux a git command like this:
git log --pretty=format:{"commit":"%H"}
gives me a valid json element, so something like:
{"commit":"20cafdecc9898113ac6215ae70cd7622dc2cae3b"}
under windows I obtain a not-valid json element, because in some way windows seems to remove the double-quotes elements and I obtain:
{commit:20cafdecc9898113ac6215ae70cd7622dc2cae3b}
Do you know why, or how can I fix it making it work under both os?
Thank you!
I assume that your shell on Linux is NOT a bash shell because my bash shell on Linux gives me the same output as on Windows - without double-quotes.
The doubles-quotes are special characters for most shells - so you have to protect them either by "escaping" or by "quoting".
git log --pretty=format:{\"commit\":\"%H\"}
git log --pretty='format:{"commit":"%H"}'
This works for bash on Linux and bash on Windows. I have not tested it with cmd on Windows.

Jq doesn't highlight Docker inspect output

When executing docker-machine inspect command, instead of the expected highlighted version of JSON piped into jq:
I'm seeing the following plain output (in cmd or ConEmu):
Not sure what needs to be done to enable proper json highlighting.
This happens on Windows 10 machine on which jq ver. 1.5 was installed via Chocolatey:
Apparently, this is an idiosyncrasy of jq Windows implementation, forcing the color output with -C option, as hinted by several commenters above, resolved the issue for me:

How to reduce whitespace from JSON on the command line without installing a tool

I've used python -m json.tool to pretty print JSON and check for errors for years. It is nice because it works on just about any system with python installed. How can I take out unnecessary whitespace that JSON ignores (i.e. not in string values) without installing on mac/linux/bsd/unix systems without installing anything special? Answers that work on recent baseline mac, freebsd and debian/ubuntu would be great.
I'm not a code golfer but I puzzled out this solution which makes a nice alias with some escaping:
python '-cimport json,sys;json.dump(json.load(sys.stdin),sys.stdout,separators=(",", ":"))'

Hart'ls Ruby Tutorial - Subl Gemfile not recognized

I'm brand new to Ruby and Rails, so sorry if this is a totally ridiculous question. The tutorial book that I'm reading says that I should be able to launch a Gemfile in Sublime Text directly from the command prompt using the subl Gemfile command. When I try this, I get an error that says "subl is not recognized as an internal or external command, operable program, or batch file".
I am in the right directory where the Gemfile is located.
Ruby is definitely installed and I am using the command prompt with Ruby and Rails.
i have the sublime text 2 and i added the path as i found,but no solution.i even tried :sublime_text Gemfile
i have tried so many different solutions but no result.
i'm using windows
Thank you in advance
the reason it isn't working isn't a rails question, it is because you haven't set up sublime to work using the command "subl" in your terminal. Try these commands. If you wish to understand the error better, just type in any gibberish into the terminal. It will tell you a similar thing.
sudomkdir /usr/local
sudomkdir /usr/local/bin
sudo ln-s/Applications/Sublime\Text\2.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl
EDIT
Sublime Text from Command Line (Win7)
https://teamtreehouse.com/forum/sublime-text-command-line-shortcut-windows
https://teamtreehouse.com/forum/ruby-on-rails-subl-command-not-found
Otherwise, you can refer to this
subl is Mac only.
For Windows, you need to add C:\Program Files (x86)\Sublime Text 2 to your Environment path,
This will work on Windows 7:
Right click My Computer, Properties, then Advanced System Settings, then Environment Variables.. Go down to System Variables, and edit PATH, you'll need to add the Path to Sublime.
Then you should be able to run sublime_text my-file from the command line. (Since the .exe is called sublime_text.exe

Why can't I create a Google Chrome extension from the CLI?

I'm a bit confused, but I can't create a .crx package from the CLI in Linux. In Windows 7 the script worked fine, but in Linux it seems that nothing happens. The popup window that occurs after the packaging process doesn't appear and the .crx is not created at all.
Here's the script.
#!/bin/sh
google-chrome --pack-extension=~/Web/client/ --pack-extension-key=~/Web/client.pem
exit 0
Maybe I'm missing something?
In Linux, (at least Ubuntu 10.04) google-chrome is a bash script wrapper of the chrome executable.
First, You should find where the chrome executable is. In my case: /opt/google/chrome/chrome
Then, replace it in your script:
#!/bin/sh
/opt/google/chrome/chrome --no-message-box --pack-extension=/extfolder/Web/client/ --pack-extension-key=/extfolder/Web/client.pem
exit 0
It is really important that in the script to specify the full path. For instance, /home/me/Web/client.pem rather than ~/Web/client.pem because as it is a parameter bash does not resolve it.
A better alternative would be defining a bash variable called $CHROME_PATH so it can be easily changed among different *nix platforms.
I don't know why packaging with google-chrome on Linux doesn't work, but can at least propose a workaround - use one of the officially-blessed packaging scripts listed at https://developer.chrome.com/extensions/crx#scripts. There is currently one for Bash and one for Ruby.