In all GUI text editors, web browsers and IDE’s you can move a cursor:

  • left/right arrows - move by char;
  • ctrl+left/right - move by word;
  • home/end - move to start/end of line.

Add Shift to any of above combination and everything you jumped through now is selected and you can: Ctrl+C, Ctrl+X,Delete to copy/cut/delete selection.

Also, you can Ctrl+Delete and Ctrl+Backspace to delete a next/previous word.

Also, you can Ctrl+Home/End to jump to start of first line or end of last line.

I want this to work when I type in a command in my Terminal.

Is it possible in Linux? It’s a vanilla experience in Windows+Powershell, thanks to default PSReadlLine extension. It works both in conhost.exe and in Windows Terminal, but doesn’t work in WT + cmd.exe, which makes me think it’s PSReadLine which is responsible for this technological perfection.

“But you can’t copy with Ctrl+C, it’s…” - You can. When something is selected It copies selection to clipboard, otherwise it sends SIGINT.

I’m not bound to any distro or terminal application, but right now I don’t see these incredible text editing techniques working even in Ubuntu+Powershell+PSReadLine, to say nothing about the Bash. I’ve tried installing WezTerm, but it doesn’t have text selection either, at least by default. And I’m inclined to think it has nothing to do with terminal emulators at all, since it works in conhost.exe+Powershell.

  • Blaiz0r@lemmy.ml
    link
    fedilink
    arrow-up
    6
    ·
    2 days ago

    I feel your pain, the only one’s I know are…

    • CTRL+a = cursor to beginning of line
    • SHIFT+CTRL+c = Copy
    • SHIFT+CTRL+x = Cut
    • SHIFT+CTRL+v = Paste
    • Alaknár@sopuli.xyz
      link
      fedilink
      English
      arrow-up
      6
      ·
      2 days ago

      You can add:

      • CTRL+K = delete everything from the cursor to the right.
      • CTRL+U = delete everything from the cursor to the left.
      • rgalex@lemmy.world
        link
        fedilink
        arrow-up
        2
        ·
        1 day ago

        And just to complement those, CTRL+Y to “yank” back whatever was deleted with CTR+K or CTRL+U.

  • felsiq@piefed.zip
    link
    fedilink
    English
    arrow-up
    7
    ·
    2 days ago

    I have everything you mentioned (except maybe the selection only stuff, I don’t use it and forget if I set it up at all) set up in my zsh+kitty setup, so it’s definitely possible. If you want I can dig thru my zshrc and kitty config for the relevant parts once I’m at my pc later.

    People in here saying it’s a bad idea for things like compatibility with other shells make some good points, but I think they’re missing one important aspect - fuck other shells, what do I care? 95% of my time in the terminal is spent on my own machine and I may as well make it convenient for myself. The odd time I ssh into another box without my keybinds I’ll be a bit less efficient, but that’s a worthwhile trade off imo.

    • podbrushkin@mander.xyzOP
      link
      fedilink
      arrow-up
      2
      arrow-down
      2
      ·
      2 days ago

      In Gnome Terminal: Ctrl+arrows work, Ctrl+delete work, home/end work, Ctrl+backspace — not, and there is no text selection, of course. So, something is working as expected without config at all, and for what isn’t working, config will not help.

      • felsiq@piefed.zip
        link
        fedilink
        English
        arrow-up
        1
        ·
        1 day ago

        I never set up text selection and have apparently never tried it till now so that one I can’t help with, but with zsh you can enable ctrl+backspace behaviour by putting bindkey “^H” backward-delete-word in your ~/.zshrc file. Ctrl+delete is bindkey “\e[3;5~” delete-word, in case you also use that one.

  • folekaule@lemmy.world
    link
    fedilink
    arrow-up
    2
    ·
    2 days ago

    This is one of the reasons I prefer using ctrl-insert/shift-insert when it’s available. Unfortunately the Insert key seems to have disappeared from a lot of keyboards. Scroll lock sometimes works instead of ctrl-s and ctrl-q. I would be ok remapping ctrl-c to ctrl-break, but I still use ctrl-z to background a job. Would be great if terminals had a quick easy way to select your preference of Microsoft, unix, or CUA shortcuts.

  • coltn@lemmy.ml
    link
    fedilink
    English
    arrow-up
    3
    arrow-down
    1
    ·
    2 days ago

    I think most of this works for me in zsh. But also tmux can help with selection; I believe by default you use your prefix then open bracket (Ctrl-b + [) to put your self in selection mode. I have some configs to use vim bindings in selection mode.

    Tmux selection:

    # Yanking
    bind-key -T copy-mode-vi v send-keys -X begin-selection
    bind-key -T copy-mode-vi C-v send-keys -X rectangle-toggle
    bind-key -T copy-mode-vi y send-keys -X copy-selection-and-cancel
    

    zsh keybinding:

    # Key Bindings
    # set vim mode
    bindkey -v
    
    # create a zkbd compatible hash;
    # to add other keys to this hash, see: man 5 terminfo
    typeset -g -A key
    
    key[Home]="${terminfo[khome]}"
    key[End]="${terminfo[kend]}"
    key[Insert]="${terminfo[kich1]}"
    key[Backspace]="${terminfo[kbs]}"
    key[Delete]="${terminfo[kdch1]}"
    key[Up]="${terminfo[kcuu1]}"
    key[Down]="${terminfo[kcud1]}"
    key[Left]="${terminfo[kcub1]}"
    key[Right]="${terminfo[kcuf1]}"
    key[PageUp]="${terminfo[kpp]}"
    key[PageDown]="${terminfo[knp]}"
    key[Shift-Tab]="${terminfo[kcbt]}"
    
    # setup key accordingly
    [[ -n "${key[Home]}"      ]] && bindkey -- "${key[Home]}"       beginning-of-line
    [[ -n "${key[End]}"       ]] && bindkey -- "${key[End]}"        end-of-line
    [[ -n "${key[Insert]}"    ]] && bindkey -- "${key[Insert]}"     overwrite-mode
    [[ -n "${key[Backspace]}" ]] && bindkey -- "${key[Backspace]}"  backward-delete-char
    [[ -n "${key[Delete]}"    ]] && bindkey -- "${key[Delete]}"     delete-char
    [[ -n "${key[Up]}"        ]] && bindkey -- "${key[Up]}"         up-line-or-history
    [[ -n "${key[Down]}"      ]] && bindkey -- "${key[Down]}"       down-line-or-history
    [[ -n "${key[Left]}"      ]] && bindkey -- "${key[Left]}"       backward-char
    [[ -n "${key[Right]}"     ]] && bindkey -- "${key[Right]}"      forward-char
    [[ -n "${key[PageUp]}"    ]] && bindkey -- "${key[PageUp]}"     beginning-of-buffer-or-history
    [[ -n "${key[PageDown]}"  ]] && bindkey -- "${key[PageDown]}"   end-of-buffer-or-history
    [[ -n "${key[Shift-Tab]}" ]] && bindkey -- "${key[Shift-Tab]}"  reverse-menu-complete
    
    # Finally, make sure the terminal is in application mode, when zle is
    # active. Only then are the values from $terminfo valid.
    if (( ${+terminfo[smkx]} && ${+terminfo[rmkx]} )); then
    	autoload -Uz add-zle-hook-widget
    	function zle_application_mode_start { echoti smkx }
    	function zle_application_mode_stop { echoti rmkx }
    	add-zle-hook-widget -Uz zle-line-init zle_application_mode_start
    	add-zle-hook-widget -Uz zle-line-finish zle_application_mode_stop
    fi
    
    
    # History - use current line up to cursor to search through history with arrow keys
    autoload -Uz up-line-or-beginning-search down-line-or-beginning-search
    zle -N up-line-or-beginning-search
    zle -N down-line-or-beginning-search
    
    [[ -n "${key[Up]}"   ]] && bindkey -- "${key[Up]}"   up-line-or-beginning-search
    [[ -n "${key[Down]}" ]] && bindkey -- "${key[Down]}" down-line-or-beginning-search
    
  • balsoft@lemmy.ml
    link
    fedilink
    arrow-up
    25
    ·
    2 days ago

    I think this is one of many un-features in Linux world where

    • It would benefit a beginner
    • It sounds simple but actually quite complicated to get right (especially if you aim to keep compatibility with things)
    • Anyone possessing the skills to implement it neither needs it nor cares about it

    As such, for you individually, I suggest just getting more comfortable with tmux (or zellij) and vi-like keybinds for text manipulation. Once you learn those (and set your readline mode to vi), you won’t look back. Oh, also, try Ctrl+x Ctrl+e in bash, it might help.

    Or switch to emacs and using it as a terminal emulator. In that case you will have to learn and use emacs keybindings, but the selection semantics in the “terminal” will be the same as in the “editor”.

    • ChaoticNeutralCzech@feddit.org
      link
      fedilink
      English
      arrow-up
      2
      ·
      1 day ago

      Add Windows-like Alt codes to the list. They’re not perfect (they use a DOS codepage and A-F in the Unicode extension clash with shortcuts in other programs like Firefox, although not passing them through via xkb would solve this) but people use them a lot, especially in my country. At? Alt+64. Backtick? Alt+96. Caret? Alt+94. Hash? Alt+38. Musical note? Alt+13. Yes, we can type most of these on the Czech layout with AltGr but people don’t know this and/or prefer things that work on the commonly default English layout too.

      • balsoft@lemmy.ml
        link
        fedilink
        arrow-up
        2
        ·
        edit-2
        1 day ago

        I prefer compose keys because they are easier to remember.

        Oh, also, I think GTK apps have that Ctrl+shift+U thing which allows you to enter characters by code. Never really got used to it though.

        • ChaoticNeutralCzech@feddit.org
          link
          fedilink
          English
          arrow-up
          1
          ·
          edit-2
          1 day ago

          I’m getting used to Compose and AltGr. Unexpected Keyboard for Android helps learn compose codes by visualizing them but it’s still a bit of resistance. And yes, Compose can also be used to input Unicode hex codes.

          Either way, I created a custom layout for AltGr and Shift+AltGr layers that is more convenient for me than remembering Compose and Unicode codes.

    • podbrushkin@mander.xyzOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      9 hours ago

      one of many un-features in Linux

      What exactly? Shift-selection is already possible with Blesh. I think I’ve seen scripts for synchronizing buffer with clipboard. And everything else is a matter of redefining existing shortcuts.

      I’ve heard about Linux being highly customizable and decentralized OS, and suddenly I can’t define my own shortcuts because there is a list of un-features?

      I don’t care about Vi and Emacs, I already have my workflow and I’m trying to transfer it to Linux. When I will succeed, then (maybe) I will spend some time to explore other ways of interacting with terminal. Otherwise, it’s not freedom, it’s becoming a victim of OS.

      • balsoft@lemmy.ml
        link
        fedilink
        arrow-up
        1
        ·
        edit-2
        7 hours ago

        I’ve heard about Linux being highly customizable and decentralized OS, and suddenly I can’t define my own shortcuts because there is a list of un-features?

        You can customize it to do whatever you want. Heck, you can write your own terminal emulator that does exactly what you need. But some things can be harder to do than others and require skills and experience. Once someone implements those harder things, they become a “feature”. Before then, therefore, they are an “un-feature”. See https://xkcd.com/1349/

        E.g. it is probably possible to set up your shell to use shift-selection for the command you’re currently editing, but shift-selection for the output of a previous command will require terminal support. You will have to make sure that the two don’t interfere with each other, which can be quite complicated.

        I already have my workflow and I’m trying to transfer it to Linux

        Linux is a different OS that, by default, does things differently from others. You can configure it to emulate some other UX, but it won’t necessarily be easy. In the meantime, you can install the micro editor, set EDITOR=micro, and then Ctrl+x Ctrl+e in bash to edit the command in a more familiar setting.

        • podbrushkin@mander.xyzOP
          link
          fedilink
          English
          arrow-up
          1
          ·
          2 hours ago

          I’m fine, I got what I wanted. Apparently, it isn’t un-feature of Linux, it’s un-feature of ReadLine which is shipped with Bash.

  • TurboWafflz@lemmy.world
    link
    fedilink
    arrow-up
    13
    arrow-down
    1
    ·
    2 days ago

    I think if we want something like that to be consistent everywhere we need to stop using Ctrl so much as a modifier for non-terminal tasks. It doesn’t solve everything, but using Alt or Super for copy and paste like Haiku and MacOS do is a big step in the right direction. It’s just hard to change an established custom without making the whole experience less consistent

    • podbrushkin@mander.xyzOP
      link
      fedilink
      arrow-up
      11
      ·
      2 days ago

      It’s nice to see you think of it as of movement towards consistency. I also look at it this way.

      But what is it about Ctrl? Text editing is historically the main task of computers, and Ctrl is the main “modifier” key. To me it seems fair it’s dedicated for some text editing shortcuts. Probably they are consistent since 1980’s.

      • pr06lefs@lemmy.ml
        link
        fedilink
        arrow-up
        12
        arrow-down
        2
        ·
        edit-2
        2 days ago

        but ctrl-c to cancel terminal tasks predates the 1980s. the inconsistency came in when apple decided to ignore that precedent and introduce ctrl-c, ctrl-x, and ctrl-v as shortcuts in their graphical UI.

        to achieve consistency, probably better to invent a new terminal type that does away with the accumulated cruft of 50 years. problem is you would also need new cli programs to go with it.

        • Alaknár@sopuli.xyz
          link
          fedilink
          English
          arrow-up
          7
          arrow-down
          1
          ·
          2 days ago

          Your comment reads extremely weird, considering both Mac and Windows handle this with zero issues.

          It’s super simple: if you’re in Select mode (any text is selected), Ctrl+C copies. In any other case, Ctrl-C is the cancel command.

    • podbrushkin@mander.xyzOP
      link
      fedilink
      arrow-up
      5
      ·
      2 days ago

      I’ve seen this and several others SO topics before posting. Some even recommend emulating a mouse with numpad. It’s like everyone suddenly start pretending not to know how text selection usually works.

  • iopq@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    1 day ago

    I would just like my inputs to be separate from the outputs. Anyone write a split pane thing?

  • Remus86@lemmy.zip
    link
    fedilink
    arrow-up
    5
    ·
    2 days ago

    I know in zsh, fish, and nushell, you can press a key combo to jump into a text editor of your choice. You write your command there, with all the power and shortcuts in emacs, vim, nano (whatever you like to use). Then you save and exit, and it appears in your command line, ready to execute.

  • stupid_asshole69 [none/use name]@hexbear.net
    link
    fedilink
    English
    arrow-up
    5
    ·
    2 days ago

    zsh shift select is probably a good start. Zsh can most likely be rebound to do what you want with the possible exception of break.

    Don’t do what you want though. It’s stupid, will make you unhappy and cause you problems.

    Your terminal isn’t powershell. Your terminal emulator is an emulation of a terminal. There is a shell that it runs, probably bash, but it’s also an emulated terminal.

    Powershell (and shells that slough off compatibility for the sake of adapting newer ideas, like zsh) is cool, but its able to be the way that it is because it isn’t a terminal emulator.

    If you change a bunch of shit around to make zsh like powershell then you can break your terminal emulation.

    Instead, either use tmux or screen bound the way you want, with their defaults or just don’t use the terminal. You don’t need to. If you do need to then you’ll be exposed to funny things like “the terminal isn’t a wysiwyg editor” and “stdio includes function keys” which require a layer of abstraction in between you and the terminal like tmux or screen, which have existed for many years and are the mature, feature rich solution to your problem.

    The benefit of not doing what you want by making yet another mutant zsh and instead adopting one of the existing solutions is that your terminal will work like all the others, so when someone asks you to try something in order to troubleshoot a problem you’ll be able to instead of having to troubleshoot how your weird garbage is different from theirs.

    Another huge benefit of not creating a special, unique zsh to do what you want is that you will gain competency with every terminal you’ll ever encounter. Which means that instead of being lost when sat down at a terminal other than your own, you’ll be just fine.

    If you want to persist in the doomed world you have created, though, oh-my-zsh documentation will probably get you most of the way to the rest of what you want.

    • podbrushkin@mander.xyzOP
      link
      fedilink
      arrow-up
      1
      ·
      2 days ago

      Than you for the link, it looks like a very close match, even though I don’t quite understand how it is related to eMacs.

      About what I’m trying to do being stupid — very interesting. What about learning vim only to notice you can’t use this skill in 70% text editing areas you interact with, and searching for firefox vi extension afterwards and trying to apply .vimconfig to it, is it stupid? Probably not. But trying to select, copy and paste text in a text-based program — that is stupid. I got it.

      • stupid_asshole69 [none/use name]@hexbear.net
        link
        fedilink
        English
        arrow-up
        5
        ·
        2 days ago

        I am not trying to insult you, I am trying to help you to not do something stupid.

        I understand that you think everything working the same would be better, I was trying to explain how that’s not the case and you will ultimately be better off not doing the thing you’re suggesting.

        To butcher a car metaphor: a peterbilt has lots more controls and gauges than a camry and they’re in different places some of the time. Wouldn’t it be better to make all the controls the same? No, of course not. A low range gearbox, intercooler temperature gauge, gigantic steering wheel with a knob and all the other differences are necessary for effectively hauling freight. Those same controls are not useful in a sedan. Do truckers have massive problems driving the grocery getter when they’re not working? No, of course they don’t. Sometimes you might give the gear selector a pull in the wrong direction but that’s no big deal.

        Instead of making a mutant terminal and dealing with all the problems that could cause you, you will almost always find it’s better to learn screen or tmux (with one of their default bindings) because then you will have a fewer problems, an easy time communicating with people about the ones you do have, and a broader skillset.

        Again, I am not trying to insult you, I am trying to keep you from doing something stupid.

        • podbrushkin@mander.xyzOP
          link
          fedilink
          arrow-up
          1
          ·
          2 days ago

          I feel like you’re just defending the final state you observe. E.g. why do you hate shift+arrows for text selection but not arrows themselves for moving a cursor? And how selecting text with a mouse is better? I find it even funny to think one of these techniques is cursed and other are blessed. Never I could imagine selecting text with Shift can encounter such opposition.

          • stupid_asshole69 [none/use name]@hexbear.net
            link
            fedilink
            English
            arrow-up
            2
            ·
            2 days ago

            I do not hate selecting text with shift. I do not even oppose selecting text with shift. The Macintosh user interface model is the standard for gui operations. It’s good to know how to use the interface of gui applications because usually the majority of your time will be spent in them.

            The terminal has a different interface. It’s different for a lot of reasons. Some are historical, some are technical, some are based on interface standards and ideas.

            I’m trying to help you understand how learning to use the terminal as it exists will be a better solution than making the terminal behave in the way you’re already familiar with.

            The reason it’s a better solution is that using the terminal as it exists allows you to more easily communicate and learn & allows you to use a broad range of tools on any system without having to import a bunch of configurations, programs or environment variables.

            It’s easy to read my comments and come to the conclusion that wanting to use the Macintosh text selection keys is the thing I think is stupid, but what I’m trying to reiterate in every reply is that making the terminal use Macintosh text selection keys is the thing I think is stupid.

            Part of learning how to use a computer is developing a combination of skills and tools that you can use to solve the problems that communicating by doing mathematics really fast always entails. I am trying to convince you to learn the toolbox the computers terminal comes with before you start to weld a tire iron on to your ratchet wrench.

            • podbrushkin@mander.xyzOP
              link
              fedilink
              arrow-up
              1
              ·
              2 days ago

              Macintosh has nothing to do with it. Maybe I want to grow selection to the left with E and to the right with R - they are not Macintosh keys, but still I will have a hard time trying to get what I want.

              Do you mean this whole concept of growing selection from the same cursor you type with and performing operations on this selected area as a single entity is a Macintosh-way, originated in GUI? And its foreign to terminals and terminals developed a different way of editing text and you propose learning this native text-editing without using foreign techniques like cursor-based text selection… This makes sense. And sure it’s possible to be effective in terminal while using it traditional way. If this is what you mean, now I understand.

              I made a glimpse on the world where this shift-selection doesn’t exist and got excited about this feature even more, and I even think it’s genius.

              System-wide clipboard is probably not the “traditional way” either, and it doesn’t work quite well in Linux terminals too.

              A couple of years ago I invested some time into Vim and it was a pleasant experience, but it was detached from all other experiences I had on my PC. Mentally switching between different text editing modes is disgusting, I hate it so much. I don’t want a new one. I’m fine with the one I have.

              Linux and its terminals are meaningful only as long as they do what I want them to do. I don’t care if some of my activities are “not Linux-way”.

              • stupid_asshole69 [none/use name]@hexbear.net
                link
                fedilink
                English
                arrow-up
                2
                ·
                2 days ago

                Yeah when I call them the Macintosh keys that’s because I’m almost 100% that the 84 Macintosh was the first thing to use them. Not just the keys specifically, but that operating model we I guess later called wysiwyg. I think it was command instead of control, but it occupies the same place on the keyboard. It’s certainly the oldest thing I’ve used that had them. Windows used to do it like old dos word processors did, with insert and delete etc.

                It’s the design and interface language of gui software for at least 40 years and everyone should know it.

                System wide clipboard would work fine in the terminal but it would be a downgrade, you’d have to give up all the lovely buffers that all your different editors use and are designed around. Even lowly less has a buffer select somewhere in there. Most of the time shift-ctrl-v lets me dump the whatever the system clipboard is out into the command prompt if I need to.

                If the idea of using a different modality for editing text bugs you so much, what do you think of the fact that you already use one? When you’re typing your fingers are on the home row and when you need to edit you switch your right hand to the arrow and function keys. It’s a lot like how editing in vim requires me to move my right hand one key over to the left.

                That way of thinking is how I was able to accept learning vi keys and vim about twenty years ago when I had the same thoughts as you about new shortcuts.

                An alternative might be using macos. I can’t remember if it uses the mac keys to cut and paste into its terminals but it might.

  • brax@sh.itjust.works
    link
    fedilink
    arrow-up
    2
    arrow-down
    2
    ·
    2 days ago
    • ctrl + left/right move by word

    I will forever hate the way vim moves by the start of the word and not the end of the word… The number of times I want to remove the last letter/s of a word at the end of a line and end up on the next line is too damn high.

    Also, don’t forget about ctrl + w to delete a full word.

      • brax@sh.itjust.works
        link
        fedilink
        arrow-up
        3
        ·
        2 days ago

        The problem is that I don’t think any of those work in Insert mode, and I hope I’m about to be proven wrong lol

    • Ignot@lemmy.world
      link
      fedilink
      arrow-up
      4
      ·
      2 days ago

      It’s two clicks, but b then e takes you to the end of the previous word in neo/vi/m

      • brax@sh.itjust.works
        link
        fedilink
        arrow-up
        2
        ·
        2 days ago

        Might have to set a custom keybind for that one to chain ctrl+right/ctrl+left to throw a :b e after

        Thx for the protip… Now all I need to do is learn how to quit it. 🤣

          • brax@sh.itjust.works
            link
            fedilink
            arrow-up
            3
            ·
            2 days ago

            Q q quit Quit QUIT x ex exit EXIT Exit EX X Leave leave LEAVE T terminate TERMINATE. SEND HELP

            Oh sorry, just pasting my vim window