Restore Previous Command in Oracle - oracle

Is there is an easy way to access the previous commands entered in Oracle? For example, when using a Linux terminal, one can press the "up arrow" key and traverse through the command history. Does Oracle offer a similar convenient feature?
Thanks in advance.

not built in, no.
In DOS SQL*PLUS this happens for you (i.e. up arrow goes to the prior command).
in linux sql*plus it does not. Having said that, there is a nice utility on linux called rlwrap that can do it for us. first install that utility and then set an alias (stick this in your .profile so that you don't have to run it every time you open a shell):
oracle#dazza-linux64:~$ alias sqlplus='rlwrap sqlplus'
now whenever you start sql*plus:
oracle#dazza-linux64:~$ sqlplus / as sysdba
you'll get the up/down arrow functionality you wanted.

In the Windows client there are two SQL*Plus command line utilities: one that's DOS-looking (sqlplus.exe) and one that's Windows-looking (sqlplusw.exe). The DOS-type version has the "uparrow" feature, plus you can press F7 for a list of previous commands, but note that it doesn't play well with multi-line commands.
The Windows-type version doesn't support uparrow or F7, but you can highlight a prior query, and copy/paste. You can also do the *nix trick of right-clicking while still holding down the left button to do the immediate copy/paste. It behaves well with multi-line commands but I have to admit I'd really love to have the uparrow here too :)

It's not a function of "Oracle" per se, it's a function of the client and/or OS. If I run SQL*Plus on Windows, for example, the up/down arrow functions as you describe.

Related

Update powershell keyboard bindings to be emacs style like bash shell

I'm fairly familiar with the default bash shell shortcuts (emacs style). For example, if I want to move my cursor forward by a word I would press Alt+F (same as you would in emacs). I can get to the previous command with Ctrl+P.
Is it even possible in windows powershell to override these shortcuts? If so, does anyone know of a good way to map the default bash shell shortcut configurations to powershell (in a bash shell you can say set -o emacs, for example)?
If it helps, I don't really care about powershell per say, I care about posh-git shell. However, git-shell inherits its properties from powershell from what I can tell.
You can do that with the PSReadLine module which ships with PowerShell 5.0 (Windows 10).
Simply set the EditMode option to Emacs:
Set-PSReadLineOption -EditMode Emacs
In addition to the default Windows mode, it also has a Vi mode.
The project README file mentions that neither are fully implemented so don't expect full feature parity, but I can confirm that it switches tab completion to bash-style and supports the Alt+F and Ctrl+P key bindings for moving forward and jumping to the previous command respectively
(I'm not an experienced emacs user so I'm unable to tell whether this comes "close enough" to what you expect)

Run mode not there (IDLE Python 3.6)

Probably a very simple question. I just thought, after someone suggested it here, of trying (and installing) Python 3.6 on a Mac - I've been happily using 2.7 since now. I've never used the IDLE before having done everything via the command line + ATOM to write the program.
I see that 'normally' you should be able to write your program in the shell and then run it in the RUN window. However, I don't see a RUN mode in window, just the possibility of using, which you are anyhow, the shell window. I hope that makes sense!
Is this normal, or have I missed something?
p.s. I'm using OS X 10.8, if that's of any importance.
I am not exactly sure what you are asking, and whether it has anything to do with OSX, but I can explain IDLE. IDLE has two types of main window: a single Shell and multiple Editor windows.
Shell simulates python running in the interactive REPL mode that you get when you enter 'python' (or 'python3') in a console or terminal window. (The latter depends on the OS.) You enter statements at the >>> prompt. A single-line statement is run when you hit Enter (or Return). A multi-line statement is run when you hit Enter twice. This is the same as in interactive Python.
Editor windows let you enter a multi-statement program. You run the programs by selecting Run and Run module from the menu or by hitting the shortcut key, which by default is F5 (at least on Windows and Linux). This runs the program much the same as if you enter python -i myprogram.py in a console. Program output and input goes to and is received from the Shell window. When the program ends, Python enters interactive mode and prints an interactive prompt (>>>). One can then interact with the objects created by the program.
You are correct that Run does not appear on the menu bar of the Shell. It is not needed as one runs a statement with the Enter key.

leave vim split window in insert mode

I want to view the output of a bash command in a vim split window :split. To this end I installed "Conque Shell" which displays bash in a split window upon :ConqueTermSplit bash. I can then run my shell command and watch the output in insert mode. However, to return to the other window I need to type <CTRL-W> <Up> in command mode, so I need to leave insert mode. Hence the display of the command output freezes and continues only if I return to this window and enter insert mode. So how can I leave "Conque Shell" without leaving insert mode.
Note that other ways of viewing the bash output in a second window might solve my problem as well. However it should update while I am working in the other window and allow me to signal e.g. <CTRL-C> to the application.
The ConqueTerm documentation says:
3.1.5 Keep updating terminal buffer *ConqueTerm_ReadUnfocused*
If set to 1 then your Conque buffers will continue to update after you've
switched to another buffer.
Note: Conque buffers may continue to update, but they will not scroll down as
new lines are added beyond the bottom of the visible buffer area. This is a
limitation of the Vim scripting language for which I haven't found a
workaround.
>
let g:ConqueTerm_ReadUnfocused = 1
AFAIK Vim has no support for asynchronous sessions, so this is more of a response to your request for potential alternative options.
The way that I currently get around this issue is by using tmux, which is described as:
a terminal multiplexer: it enables a number of terminals (or windows),
each running a separate program, to be created, accessed, and
controlled from a single screen.
So, basically, instead of splitting your screen in Vim you would split it using tmux, and then in one window run Vim and in the other run whatever other program you want which will update completely independently of Vim. And just like Vim you can switch between the windows (or panes as they are called in tmux lingo) using a couple of key strokes.
There is another terminal multiplexer available called GNU screen, which is also quite popular. And the reason I mention that is because I like to have options, and also there are two plugins for Vim that allow you to send output directly to an attached screen or tmux session. For GNU screen, slime.vim, and for tmux, tslime.vim.
Using VIM and ConqueTerm you can use CTRL + W and UP / Down to change windows in split mode.
Just click on ESC first to exit the insert mode.
It works well on my side.

How to map Shift-Tab in vim? (Cygwin, Windows cmd.exe)

I see a few entries here about making Shift-Tab work in vim, but none of them addresses the failure when it's in Cygwin, running at a Windows command prompt. In that environment, Shift-Tab works for me exactly like an unshifted tab, and my attempts at remapping have failed:
:imap <S-Tab> ^D [ this is a real Ctrl-D, entered with Ctrl-V before it ]
:imap [ typed Ctrl-V, Shift-Tab here; got a Tab character inserted ]
So it seems that the Shift modifier is being ignored. Any thoughts about how to proceed? Thanks.
That won't work in the Cygwin console because it sends the same keycode for both Tab and Shift+Tab: ^I.
You might want to install Cygwin's mintty terminal emulator, which sends the standard keycode for Shift+Tab: \e[Z.
Instead of messing with the Cygwin version, I suggest you remove it and install the native version instead. With that, you can map Shift-Tab without issues, even when starting Vim from a bash shell.
I don't have windows right here now, but look whether your vimrc contains
behave mswin
source ...\mswin.vim
In that case,
:e +g/mswin/norm!\ 0i" $MYVIMRC
should automatically comment these out. Relaunch vim, and inspect whether there are existing mappings:
:verbose map <S-Tab>
will show you any existing mappings, and where it was last defined, so you can find the script/plugin that is causing this (:he :verbose-cmd)
HTH
Update to the comment:
Well - blimey, turns out that Shift-Tab is magically impossible with Win32 Consoles. Never noticed.
Perhaps it is because I
use mintty these days, to provide a much better experience (Unix like copy pasting, real alternative terminals, more performance, and re-attaching screen sessions, e.g.)
might have tweaked the CompletionChar setting although this seems like a loose fodder even to me
Could you try with mintty? I'd think I'd have noticed such a hairy incompatibility over the years. But, you never know :)

Better windows command line shells [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
Is there a better windows command line shell other than cmd which has better copy paste between Windows' windows and console windows?
Enable QuickEdit mode, under the Options tab of your shortcut to the command shell. Mark with the mouse, right-click to copy, right-click again to paste.
While you're there, enable a hotkey (like CTRL + ALT + C) for lightning fast access to the shell.
And no, you can't have CTRL + C for COPY, because CTRL + C means BREAK.
On a related note, the Microsoftee who changed the default setting of QuickEdit mode between Windows Server 2000 and 2003 is an idiot and I heap curses upon him each workday.
Windows PowerShell is the obvious choice when it comes to "better windows command line shell other than cmd". Its clipboard handling isn't that much of an improvement - mark with the mouse, Enter to copy, or right mouse click to paste.
This probably is not exactly what you want, but you can take a look at Console2
I have it configured so that shift+select auto copies and middle click pastes, really handy, internally it uses same old cmd.exe so you are not really getting a different shell.
By the way, I guess Ctrl+C = copy is not the best idea in a command line context because it usually means interrupt running process.
Take Command does support Copy/Cut/Paste from the keyboard and the mouse. It's pretty handy if you do a lot of work from a command prompt. It also supports:
Command and folder history, with popup windows to select prior commands or folders.
Screen scroll back buffer
Enhanced batch commands
Built in FTP/HTTP file access
A toolbar with programmable buttons
Note: It's a paid tool, with price of $99.95.
Depending on what you're trying to do with the shell, rxvt in cygwin is good.
You'll get the nicety of auto copy on selection and middle click paste. The biggest downside is that some windows console apps don't play nice with cygwin.
PowerCmd is cheaper than TakeCommand and has a lot of powerful features - not the least of which is better handling of Cut/Copy/Paste. I've only been using it a short time but I'm really impressed so far:
Summary from the site:
PowerCmd enhances your command prompt
with an easy-to-use Windows GUI-style
interface and allows you to run
multiple consoles within a single
tabbed window. You can easily organize
multiple consoles in vertical,
horizontal, and grid forms. Auto-log,
auto-completion, keywords highlight,
configurable font and colors,
customizable toolbar for frequently
used commands or tools and minimizing
to tray are easy solutions to daily
needs. With PowerCmd, you can save and
restore your sessions from last time.
Site:
http://www.powercmd.com/
Features:
http://www.powercmd.com/features.php
Not sure what specifically you mean by better copy/paste but try Take Command.
Take Command supports Shift+Ins for paste and Shift+Del for cut, but apparently nothing for copy, will dig some more.
There are two portion to cmd.exe. First there is the window that pops up for dealing with the text console. I would replace that with ConEmu. That program is actually meant as a wrapper for the Far File manager but works just fine without it. It is very similar to Console2 but also is much more stable and has better features.
Second there is the command line interpreter. I would replace that with Powershell if you actually need any of its features.
I currently run using ConEmu with a batch file to setup my preferred environment. This is kept in my Dropbox folder so it remains synchronized between my computers.
Have you thought through what behavior you want to replace the current Ctrl+C functionality?
Console 2
http://sourceforge.net/projects/console/
http://www.hanselman.com/blog/Console2ABetterWindowsCommandPrompt.aspx
#Chirs
I think you need to clarify shell vs host(emulator). To me it sounds like you need another interface to your existing shell that better supports copy and paste, not another shell that supports more/different features.
I second Pat's suggestion of Console2, it is a very good application and OSS to boot.
The Windows cmd shell, Cygwin Bash, and msysgit Bash shells can be run within Emacs. EmacsW32 provides all three separately. You just have to set the bin directory to use either of the Bash shells. EmacsW32 also provides limited interactions between the Windows clipboard and the top item of the kill ring.
MinGW Shell properly set up with:
right click menu entry
~/.profile file
is well above anything else I have tried.
MinTTY on MinGW/MSYS is nice—nicer than on Cygwin because MinGW/MSYS is faster. Also, if you need cmd.exe behaviour, you can run cmd.exe inside of mintty easily.
See http://code.google.com/p/mintty/.
I use the standard CMD.EXE shell but with a twist: an AutoHotKey script to support clipboard copy-paste as posted in: Keyboard shortcut to paste clipboard content into command prompt window (Win XP)

Resources