[Revised] Ksh reddit / BSD ---------------------------------------------------------------------- [deleted] · 2019-02-01 22:03 [deleted] ---------------------------------------------------------------------- LostToll · 2019-02-02 02:30 Is it a joke, isn’t it? Tell me you’re just kidding, please... ---------------------------------------------------------------------- [deleted] · 2019-02-02 02:32 I'm confused... edit: If there is some missing information that would be helpful please let me know. I would like to solve these and want to supply all the helpful information I can. ---------------------------------------------------------------------- LostToll · 2019-02-02 02:42 Two things are really confusing here, IMHO. You wrote an essay, literally. To answer all the questions you asked it takes to write a book. Also, the reason for switching seems quite strange to me. You say that ksh is amazingly good. I can’t argue this because I have never used it. Could you please explain why it is so important to you to spend the hours at least to recreate your current zsh configuration for ksh? What are the benefits? These shells are quite different as far as I know. It’s not a trivial task. ---------------------------------------------------------------------- [deleted] · 2019-02-02 02:51 I wanted to write a proper descriptive post to provide all the information I could for anyone offering help as I know it can be difficult to help someone when you don't have all the information. So I just wanted to make sure I gave all the information I could think of. My reason for changing shells from zsh to ksh is that I want to minimize my dependency on extra packages. I had been having some issues with zsh for sometime (that being said it a wondeful shell and anyone who reads this, please try it for yourself. Even though I didn't end up sticking with it, you may like it.). It has always been slow for me and I feel that zsh has many features I don't and won't use as do many other shells. I have been very interested in the "suckless philosophy" as well and know that ksh is not only small, but also a part of the OpenBSD base system. Thus I want to swap to it. Many friends heavily recommend it and I find it very nice to work with, it is quick, clean and very well made. I apologize if I post was a bit long, I just want to provide all the information I can. ---------------------------------------------------------------------- Kernigh · 2019-02-02 03:15 (This is for OpenBSD ksh. Some features are not the same in other ksh variants.) **To move the cursor to the right,** see [terminfo(5) Cursor Motions](https://man.openbsd.org/man5/terminfo.5#Cursor_Motions); you can get the escape sequences from [tput(1)](https://man.openbsd.org/tput). I had trouble with *hpa* (horizontal position absolute), but I can use *cuf* (cursor forward) and *cub* (cursor backward): pehcehwahn$ tput cuf 75; echo -n right; tput cub 80; echo left left right The word "right" was in columns 76 to 80 on the same line as "hi". (I have pasted this into Reddit as "hi", 73 spaces, "right".) You may [vis(1)](https://man.openbsd.org/man1/vis.1) sequences: pehcehwahn$ tput cuf 75 | vis -o; echo \033[75C pehcehwahn$ tput cub 80 | vis -o; echo \033[80D So `PS1='\[\e[75Cright\e[80D\]\h$ '` adds "right" to my shell prompt. The commands `tput lines` and `tput cols` show the terminal's size; you might use `tput cols` with [ksh(1) Arithmetic expressions](https://man.openbsd.org/ksh#Arithmetic_expressions) to find the right side. In the next example, the terminal had 55 columns. $ cols=$(tput cols) $ echo $cols 55 $ echo "\033[$((cols - 5))Cright\033[$((cols))D" right **In the hacker quotes script,** OpenBSD ksh doesn't have the `ksh93 array=(a b c)` syntax for arrays. You might try `set -A array a b c`, like you have in the completions script. **To get arrow keys in vi mode,** you might need to edit the C code of ksh itself. I can use the arrows in insert mode in [vi(1)](https://man.openbsd.org/vi), but not in ksh(1), so ksh might be missing some code. My up arrow sends ESC \[ A to the terminal; ksh is not seeing the arrow, but literally doing ESC (switch to insert mode) \[ (nothing?) A (append to end of line). I don't see a way to change what happens when a command isn't found. ---------------------------------------------------------------------- deftly · 2019-02-02 03:20 The prompt is not going to be a trivial task. Zsh has a feature to park things in the right hand side, OpenBSD’s ksh does not. It might be possible with tput. But the amount of tinkering it would take is going to be never ending. As for the completion stuff. Make sure you are using the “_1”, “_2” variable names correctly. They represent the order of the arguments. (I wrote the blog post on deftly.net :D) In a world of “suckles mentality” tools, forcing said tools to do things that “suckmore” tools do is really going against the grain. ---------------------------------------------------------------------- LostToll · 2019-02-02 03:20 ‘Minimize the dependency on extra packages’ - sorry, I can’t agree with you. Correct me if I’m wrong but ksh is rather exotic nowadays. If you plan not to use any OS but OpenBSD, well, then it could be a reasonable choice. For a purist at least. Also, why you call zsh slow? Slow for what? Do you mean its interactive abilities or scripting? ---------------------------------------------------------------------- [deleted] · 2019-02-02 03:28 Thank you so much for that post, it was extremely helpful. I will likley make a different prompt in that case, but now I have to redesgin haha. Agreed on the making suckless tools suckmore being a bad idea, I am loving ksh so much. ---------------------------------------------------------------------- [deleted] · 2019-02-02 03:44 I can't use arrow keys in ksh without adding to the code? Hmmm, I guess I could try to get use to that, but that's kind of a pain. I am unsure what I am gonna do prompt wise, I may have to sleep on it. For me at this point I just need to find a way to design the style prompt I want with the proper information in it. The design will be the pain :/. I am looking to hopefully contribute code to OpenBSD in the feature, do you know if they'd be responisve in a positive way to something like this? ---------------------------------------------------------------------- [deleted] · 2019-02-02 03:47 Zsh always ran very slow for me. I tried it on many machines, but it was always not only slow itself, but seemed to slow down the rest of my machine. I don't reallt use much in zsh except autocd, the tab completion, syntax highlighting and a few other select things. I plan to one day write my own shell to get the perfect enviroment I am looking for. But for now I am gonna stick with ksh. ---------------------------------------------------------------------- [deleted] · 2019-02-02 04:04 I hate to ask this as this is probably a very noob question, been looking online and trying all sorta of numbers. How would I make a color red? Like I have this: `neon_pink="\[\e[1;32m\]" # neon pink` but I just can't get red, I have no idea why. I am redoing my prompt, the red is for the frowny returned on an error. Aww man... this is driving me crazy... I have no idea what to do prompt wise :( ---------------------------------------------------------------------- deftly · 2019-02-02 04:15 "\033[01;31m" ---------------------------------------------------------------------- [deleted] · 2019-02-02 04:18 > \033[01;31m that uses neon blue too. Hmm, it may help if I link [my terminal color scheme](https://gitlab.com/Puffles_the_Dragon/pt/blob/master/config.de f.h). Also if anyone has any ideas for a nice chinese cyberpunk esque prompt I'd love to hear :D ---------------------------------------------------------------------- deftly · 2019-02-02 04:25 Ah. You are in your own with st. That string I gave ya works in xterm and rxvt as expected. ---------------------------------------------------------------------- LostToll · 2019-02-02 04:25 ‘Curiouser and curiouser!’ cried Alice. ---------------------------------------------------------------------- [deleted] · 2019-02-02 04:26 Ahhh. Yeah, I have been working with st and love it. ---------------------------------------------------------------------- [deleted] · 2019-02-02 04:27 "Praise the Sun!" - Solair ---------------------------------------------------------------------- [deleted] · 2019-02-02 04:29 *watches kai Hendry videos* a single line prompt is cool.... ---------------------------------------------------------------------- [deleted] · 2019-02-02 04:44 [This isn't too bad](https://share.riseup.net/#hgIubOygWGgpUxqrS_VIKg). Add a new line to the bottom and work in \j and this isn't too bad. ---------------------------------------------------------------------- [deleted] · 2019-02-02 04:52 What do you [think](https://share.riseup.net/#nYJXzftP0SleSSr9ohEMlA)? ---------------------------------------------------------------------- Kernigh · 2019-02-02 05:49 I'm less than sure about the code, because I haven't looked at it. If you do make a diff, I don't know how OpenBSD developers would respond. ---------------------------------------------------------------------- deftly · 2019-02-02 10:10 Looks nice but it’s not my cup of tea. ---------------------------------------------------------------------- [deleted] · 2019-02-02 14:44 Do you by chance know how I would add a newline below the prompt? ---------------------------------------------------------------------- [deleted] · 2019-02-02 17:56 Uhhhh, something **very** weird is happening... when I compile C code my prompt turns into [this](https://share.riseup.net/#Uk0QQfnyf3i613fluhMJaQ), help :( ---------------------------------------------------------------------- ben_bai · 2019-02-03 16:49 1.) insults: seeding $RANDOM is not necessary on OpenBSD. It weakens the results because it switches to a deterministic PRNG. 2.) smiley script: some work some don't 3.) hacker quotes: would be nice to create a fortune(6) file and let fortune handle the rest. ---------------------------------------------------------------------- [deleted] · 2019-02-03 22:22 I got smiley added, but I can't figure out how to add a newline at the end of my prompt (it would show beneath the prompt for better spacing) and I can't get the others to work. ---------------------------------------------------------------------- okapi-a · 2019-02-06 14:43 Zsh is only slow if you run crappy frameworks on top of it - stuff like oh-my-zsh. Use a basic setup without syntax highlighting, and it'll be much faster. Git branch information in the prompt also doesn't tend to help. Mostly because git ends up searching for a .git directory in parent directories - which can cause the automounter to contact NFS servers. Completion can be slow where it has to query something that is slow but overall, I find it makes me much much faster at doing what I want to do. ---------------------------------------------------------------------- [deleted] · 2019-02-06 15:09 I didn't use any frameworks what so ever and even with the default setup it was slow. Edit: If I am reading this right, it seems all the things that make zsh well zsh make it run slow...