Live data from Hacker News

Linux Terminal Goods

diego-pacheco.blogspot.com

41–50 of 65 posts

Re: Linux Terminal Goods

#41

Maybe I'm completely missing the point of `bat` but I usually just use `view` (vim/neovim in readonly mode) if I want to read files with syntax highlighting, GitGutter, line numbers, etc.

It's a similar idea to that, but it's more lightweight and much more of a "drop-in replacement" for both cat and less. For instance, when using it as a replacement for "less", it will use terminal colors correctly (i.e. "ls --color | bat" works like you'd want), it will have the same keybindings as less (i.e. b/f for page back/forward, / for search, q for quit, ...), it wont have a cursor, etc. Essentially "less and cat but way better".

Vim can certainly do all these things (or mostly, I don't know about the terminal colors), but for viewing read-only text streams, it's a bit more domain-specific and convenient. It's also blazing fast to open, which vim isn't always.

Re: Linux Terminal Goods

#42
post #27

Maybe I'm completely missing the point of `bat` but I usually just use `view` (vim/neovim in readonly mode) if I want to read files with syntax highlighting, GitGutter, line numbers, etc.

Not sure if view lets you do this but bat will switch off highlighting if you are piping output `bat file.txt | grep ...`. This makes it easy to make an alias cat=bat and have everything work. Also you can make bat display output with `less` and then line numbers can be toggled, not sure about gitgutter.

(author of bat here)

Exactly. Drop-in compatibility with 'cat' is one of the goals of bat (see https://github.com/sharkdp/bat#project-goals-and-alternative... and a list of alternatives here: https://github.com/sharkdp/bat/blob/master/doc/alternatives....).

Another thing that I use frequently is previewing a whole set of files in a single (pager) output. Something like

    bat src/*.cpp
This also allows you to easily search across a whole set of open files.

Re: Linux Terminal Goods

#43
post #24

I spend loads of time in a shell. One day I'll push my full dotfiles publicly, but until then here's a few snippets I've found super handy. I'd advise against using them verbatim but there's a few things in there that took some time to figure out. Beware they can be somewhat buggy / break things though. Highlights include: - Bind C-c/C-v to Copy/Paste, bind C-g to sigterm (Note: Breaks docker interactive unless you m…

Inspired by a colleague, I wrote this (for bash): https://gist.github.com/archi/2a2331401842c0548fa8de0f69796f... > up 4 go up 4 folders (=> "cd .." 4 times). > up goes up one folder, and you can repeat pressing ENTER to go up one more. Press anything else to drop back to the shell. Could probably be "better" (e.g. no subshells), but works well for me.

I've written aliases like cd2='cd ../..'. similarly cd3='cd ../../..' . Similarly cd4 and cd5. next time I'll think of this!

Re: Linux Terminal Goods

#44
post #42
post #27

Earlier quoted context omitted.

Not sure if view lets you do this but bat will switch off highlighting if you are piping output `bat file.txt | grep ...`. This makes it easy to make an alias cat=bat and have everything work. Also you can make bat display output with `less` and then line numbers can be toggled, not sure about gitgutter.

(author of bat here) Exactly. Drop-in compatibility with 'cat' is one of the goals of bat (see https://github.com/sharkdp/bat#project-goals-and-alternative... and a list of alternatives here: https://github.com/sharkdp/bat/blob/master/doc/alternatives.... ). Another thing that I use frequently is previewing a whole set of files in a single (pager) output. Something like bat src/*.cpp This also allows you to easily se…

Awesome work. I've been a happy user of bat for a few months now, I've almost totally trained my brain away from typing cat.

Re: Linux Terminal Goods

#46
post #38

Earlier quoted context omitted.

Thats cool! I'm not sure where it comes from, but I get similar behavior in zsh with 'cd ....' - similar doesn't happen in bash though. I mapped 'cd' to 'c' in my bashrc, but while doing it I also mapped 'c' to execute 'ls' as the latter was basically muscle memory whenever I was using cd. The .bashrc function looks like this: c() { builtin cd "$@" && ls; }

Hey guys, I have the same thing, but I called the command ".." (no it doesn't conflict with the directory). ".." by itself is the same as ".. 3" .. () { local arg=${1:-1}; while [ $arg -gt 0 ]; do builtin cd .. &> /dev/null; arg=$(($arg - 1)); done; }

Mine is similar, but only does one cd command - to allow better use of `cd -`

    up() {
        local ups="."
        for((i=0;i

Re: Linux Terminal Goods

#47
post #7

I've just skimmed around it as someone who repeatedly need that kind of book to achieve little things in bash. I understand bash is the basis of so many things, that its importance is just enormous. But at the same time, I'm appalled by its syntax, idioms, etc. It's barely readable for the casual reader that I am. I wonder why nobody tries to provide a meaningful alternative. I've seen some (in python for example) bu…

It's not syntax. It's programs. [ Is a program. Bash blew my mind when I found that out. What a clever idea.

I know what you mean though. I always had to look up things every time. Lately I just committed a bunch of it to memory as it's useful enough and I'm pretty fond of it.

Re: Linux Terminal Goods

#48
post #7

I've just skimmed around it as someone who repeatedly need that kind of book to achieve little things in bash. I understand bash is the basis of so many things, that its importance is just enormous. But at the same time, I'm appalled by its syntax, idioms, etc. It's barely readable for the casual reader that I am. I wonder why nobody tries to provide a meaningful alternative. I've seen some (in python for example) bu…

Bash is similar to vim. Pretty weird at first glance, but once you get the idea, stuff just makes sense and the limited knowledge you acquire can be used in different contexts. I think bash is magical in the things it allows you to do with minimal effort.

Re: Linux Terminal Goods

#49

Regular vim has tabs and you can bind any key you want to switching them (I use F2/F3). The default is :next and :prev or gt/gT. I’ve been using the feature for years now. You can also open a list of files in separate tabs with the -p argument. So “vim -p CppFile.*” will open the .h and .cpp in separate tabs for example. You can then Y/p between the two buffers. It’s so useful that I always “alias vi=vim -p” in my .p…

Is the '-p' necessary?

I like to open files in windows with e.g. "vim -O file1 file2", and I've noticed that if I accidentally omit the '-o' or '-O', it opens each file in a tab. Or at least, it opens each file in individual pages that you navigate between with ':next' / ':prev'.

Re: Linux Terminal Goods

#50
i really wish spacemacs didn't have that pretty lame loading screen, as a spacevim devotee i found alot of things that spacemacs does that specifically address some issues i have with spacevim.

i know the correct path forward here is, of course, diving into the guts of spacevim and tinkering until it works for me, but i will post one quirk as it will probably be some time before i will be able to write my own comprehensive plugin:

the hugofy/markdown plugins seem to all do this awful thing in which they render the markdown on the fly. it's kinda neat for basic text formatting, but my god it is an utter nightmare if you have any sort of URL's or images, because the second you key in that second bracket, it suddenly dissapears and you're left having to basically guess your way through the process of typing the url and closing out the shortcode.

if someone knows of a markdown editor that plays nice, i'd love to see it. hope im not overlooking something painfully obvious here

anyways, i picked a hell of a time to dive into the commandline, a year ago i came across scoop/chocolatey and quickly discovered WSL, and thanks to a phenomenal amount of work by some great folks (even you, Person Reading This), my desktop is not much more than the lobby i pass through before going to where the magic happens: https://imgur.com/a/iCpWZAC

Post reply on HN