Powershell commands? - powershell

Ok I'm having trouble and google isn't helping, so I thought I'd come to you geniuses. I'm using Powershell and posh-git, and it keeps doing something that I'm sure I can exit out of with a magic command, I just don't know it yet.
Basically, when I run git diff (or something else with a long result), it will only give me a screen's worth of information, and end the screen with a colon
:
And if I keep pressing Enter it will add more to the screen til it is done showing everything for that command, and shows
<END>
But now what? How do I get out of this and back to calling commands? Enter, Esc and the other things I thought to try are not helping. I'm sure this must be a simple thing, but I don't know how to explain to Google what I want.
Anyone know?

if you do a git config -l you may see some relevant entries like:
core.pager='less'
pager.diff=false
pager.log=true
You can enable or disable the pager for different commands, or set a different pager. https://www.kernel.org/pub/software/scm/git/docs/git-config.html has the details, check out the core.pager section and pager.<cmd> sections for specifics.
If you're using 'less' as your pager, hit 'h' at that : prompt to get lots of details about what you can do there, and as pointed out by others, q, Q, or ZZ will get you back to the command line.

You can terminate the current command using CTRL+C. Is that what you're asking?

Related

Cursor not in right location and can go beyond $ sign in VSCode terminal

I connect to remote host in VSCode. Then let' say I type the following command in VSCode terminal
sh ./environment/activate_python_jupyter.sh
and then I realize that I should use the pyspark one instead of the python one, so I use up arrow to find the above command, and use left/right arrows to locate my cursor to modify thon to spark. The modified command looks like this before I hit enter
sh ./environment/activate_pyspark_jupyter.sh
However, after I hit the enter I find out that the modified command is not the one I see before (checked by up arrow), it might be something like this
sh ./environment/actispark_python_jupyter.sh
I try several times and each time the modified command looks good/turns to a different and wrong one before/after I hit enter. I finally realize that it is because the cursor was actually not located in the right place when I modified the command, although it looked good before I hit enter.
More interestingly, my cursor can go beyond the $ (dollar sign) when I use up arrow to find a command and move the cursor using the left arrow. 
This looks like a cursor location bug. Have someone met with such issue and happen to know a solution?

fish shell + omf + git plugin: how to customize the prompt in the terminal

I have fish shell with omf with agnoster theme and git-plugin installed.
I would like to tune my prompt a bit. Does anyone here know where/how I do that. I ran fish_config; but that did not show my current prompt properly. So I am reluctant to go that route. I would rather do it by typing it in; but can't figure out where the final prompt is being stored. I tried 'echo $fish_prompt'. Did not help.
Would appreciate some help. Thanks!
fish_prompt is a function. See https://fishshell.com/docs/current/cmds/fish_prompt.html. To see where it is defined run functions --details fish_prompt. There is no "final prompt [is] being stored" as I understand that phrase. There is a function that creates the prompt. Your echo $fish_prompt would only output something useful if the prompt was a literal string (which isn't supported). You can use functions --all fish_prompt to see where it is defined and the content of the function.
When I used Fish I did not use OMF (I'm now an Elvish user). I had a custom function defined in ~/.config/fish/functions/fish_prompt.fish. So I can't explain how to customize the OMF "agnoster" theme prompt. You'll need to read the documentation for that theme to learn what knobs, if any, it provides for customizing its behavior.
Short answer: edit function fish_prompt in file: .local/share/omf/themes/agnoster/functions/fish_prompt.fish.
Explanation:
This exact file may not work in cases with different plugin's and/or different theme.
The way I figured this was to search for all "*prompt.fish" functions in my home directory. Put a distinct print statement with the prompt in each one of them and check which one got printed and modified the fish_prompt.fish function in that file - which is working for me!

Is it possible to take control of sublimetext3 tabs with cmd

Good Day.
I am a hobby programmer, and am just looking for creative ways to get things done.
In particular, closing a tab or tabs in sublimetext3 through a cmd line method.
The even cooler thing would be, if so, is there a way to decide in cmd which tab to close e.g. 3rd from left/right etc?
In keeping with the idea that this is mostly curiosity and preference than anything else, so creative replies are definitely appreciated as well.
You can execute any command* from the command line, so this is very much possible.
For example, to close the active tab of the most recently used Sublime Text window, you can run subl --command close.
To close a specific tab, for example the 18th tab, which will have index 17 because it is zero-based:
subl --command 'close_by_index {"group": 0, "index": 17}'
(This is assuming bash syntax - for Windows cmd syntax, you may need to do some creative escaping because the command arguments have to be valid JSON and quoted as part of the same argument as the name of the command you want to execute.)
This is exactly the same command that would be run when right-clicking on the tab and picking Close Tab in the context menu. This command can be seen by inspecting Packages/Default/Tab Context.sublime-menu using the built-in View Package File functionality in the Command Palette. You can check this file to see other pre-defined entries like closing all other tabs, or tabs to the right etc.
*: Caveats being if ST is not already running, then it tries to run the command before plugins are loaded.

Scrolling "too long" command doesn't work properly

Assume I want to invoke a tool with a lot of options, like:
$ somescript --option1 --option2 --option3 --option4 --option5 whatever even more stuff
But the width of the terminal doesn't allow to have that thing on a "single line".
That alone isn't a problem, but with fish, there is a problem with scrolling.
When I enter that extra-wide command, at some point, there will be a line break:
$ somescript --option1 --option2 --option3 --option4 --option5
whatever even more stuff
All fine so far. While typing such a lengthy command, I can scroll forth and back at any point. Works as expected. So, assume I entered the command, made a mistake, and now want to remove --option4.
The normal thing: use "arrow up" to get to that command in the history, to then use "arrow left" to scroll within the command. And now something weird happens.
Everything is fine while the cursor is within the second line. But when the cursor moves to the first line ... after 3 to 5 more "arrow left" strokes, the cursor moves UP another line. Then it sits above the first line of the command. There is also a vertical jump of a few characters.
In other words: as soon as a command is longer than the width of the terminal, I am unable to scroll into the first line reliably. The cursor shows up somewhere, and it is really hard to guess where it really sits at any moment. Which makes it almost impossible to edit anything in that first line.
This is on MacOs, using iterm 3.2.9 and fish version 3.0.2 installed via brew.
Wrote up defect 6014 on github. Outcome is rather frustrating.
The problem is: the Mac terminal(s) all handle certain unicode characters the wrong way. "Normally" that isn't a problem, but when you use one of those fish prompts that give you the git status (like AcidHub which is my favorite) ... fish can't compute/determine the exact line width, and there you go.
So, basically, when using fish on MacOs, option space is limited to:
use the defaults, which (when using special prompts, like AcidHub will lead to scrolling issues)
adapt the fish prompt accordingly (in my case, I replaced all special unicode chars with something simpler). It doesn't look that great, but scrolling simply works again.
And a completely different and unexpected solution to the problem: I am using iterm2 on my Mac, and iterm2 just added a "status bar" section. That can be easily configured, and of course, it already has a status bar component that tells you about git status.
Thus my solution: I changed the fish prompt to just give the PWD, and all the other things that the AcidHub prompt has to offer, are now "iterm2 status bar" components!

Would it be possible to jump between prev/next Terminal command prompts?

I'm using zsh in OS X Terminal.app and for quite a while, I've been longing for a way to jump back and forth between prev/next prompts in the terminal's output.
One convenience with this would be to be able to review (and track errors at) the end of each command's output; eg. when you building stuff from source with ./configure; make; make install. Note: I'm obviously not referring to jumping back and forth in the command-history, but for a way to take a peek at the endings of each command's output.
Has anyone heard of such functionality in the *nix (preferrably also Mac) world? Would it require some sort of OS-centric Terminal plugin, or can it be programmatically done via a shell script which can be tied to a keyboard shortcut? Maybe I'm the only one thinking about this? :)
Edit: Here's an example scenario: Let's say I want to compile and install some program (using standard ./configure && make && make install procedure) and after the make command, I run into some errors. Now, the way I understand it (I may be completely wrong), the crucial error causing the make command to fail usually shows up in the last line(s) in the output, no? Anyway, at this point, I might do something like cat INSTALL to read up on the INSTALL document to check whether there's something I've missed. NOW, if I want to go back to see what the error was, that caused my initial make command to fail, I then have to manually scroll up to that position again, since my cat INSTALL command printed a ton of text after it.
I don't know if this scenario is the most elucidative – but there are many other situations where I wish I could just "jump" back to previous prompt lines and check up on previous command output; whether it was a simple ls command, make, git status, or whatever it was – swapping positions in the window by means of using prompt lines as "bookmark" positions seems an interesting idea to me.
command + left or right goes between tabs in iterm. is this what you are asking?
Emacs has a shell-mode that runs a shell inside the Emacs editor, providing a rich environment of additional commands for navigating and working with shell commands. This includes commands for going to the previous/next prompt, and deleting the output from commands so you can "clean up" and issue another command.
If you aren't familiar with Emacs: to start a shell inside Emacs, run emacs from the shell, then type Esc-x (or Meta-x, if you have "Use option as meta key" enabled in Terminal > Preferences > Settings > [profile] > Keyboard). This will ask for a command to execute. Enter shell.
To see a list of commands you can use in Shell Mode, enter Control-h m. Here are the ones for moving the cursor to the previous/next prompt:
C-c C-n comint-next-prompt
C-c C-p comint-previous-prompt
These commands would also be useful:
C-c C-r comint-show-output
C-c C-o comint-delete-output