This question already has answers here:
Closed 13 years ago.
Possible Duplicates:
Favourite command line trick
useful linux commands for programmers?
What is your single most favorite command-line trick using Bash?
I have recently become accustomed to doing most of my development (in various languages) from the bash shell, using command-line tools and interfaces. I have discovered it is convenient to stay in the command line because you can do many things without leaving that interface, and it is fast.
What tools and tricks are you aware of that can make bash (perhaps in conjunction with an editor like vim or emacs) a more powerful development environment to work in?
Start with an X11 window manager that works well without needing a mouse.
Awesome
xmonad
After that:
screen
bash_completion
vim
cscope
ctags
remake
I rarely need to touch the mouse for anything.
You've probably done some or all of this, but for the record...
ctags/etags
plugins for vim and emacs
get to know the bash ! history substitution feature (but be careful! :-)
if using vi (over emacs) then get to know the :line mode
you might want to check out the id-utils package
if using bash on windows via cygwin, use rxvt instead of the default dos box
You also want to set up each tool in the programmer mode. Editors like vi and emacs can autoindent, show matching parens, etc. You need to read the help and turns these things on. Be sure that you run bash in the history mode that matches your editing reflexes. It defaults to emacs but for vi one does set -o vi.
First, I use intensively shortcuts. Then, I could obviously mention things like vim, grep, tail, head, find, sudo !!,... But one thing I really can't live without is Programmable Completion. Of course, this will depend on your habit, but here are some must have for me:
Ant Bash Completion
command line completion in GlassFish
Grails Bash Completion and/or Autocomplete Grails Script Names in bash/zsh
Maven Tab Auto Completion in Bash
Oh let's see... cut, sort, grep, find
Related
I'm running wish (as part of the TCL/TK 8.6 distribution) in a mac terminal window.
Unfortunately, I can't recall and edit previous commands.
A long time ago (think 15 years ago) there was some clever program that trapped all user commands so you could recall and edit old commands before sending them to a program that could not edit old commands.
I think it was called FOP (but I might be wrong here_ and it ran on Linux
So I'd say
> FOP wish
and then I'd be able to recall and edit previous commands.
Is there any such program that I can use that does this - so that I can edit old wish commands?
The usual package for this sort of thing is rlwrap, which lets you put a readline-based wrapper around programs such as tclsh. It's an optional package — called rlwrap, obviously — in the usual distribution sources for CentOS, Debian and Ubuntu (as well as both MacPorts and Homebrew, for people on macOS) so installation is pretty straight-forward.
Once you've installed it, you then do:
rlwrap wish
and enjoy your more sophisticated input capabilities.
There are probably other packages capable of doing this sort of thing, but rlwrap is very easy and pretty well recommended; I've not heard of anyone using anything else except for reasons of outright bloodymindedness.
I'm using SICStus 4.2.0 and I was not able to find out how to clear the content of the console. Is it even possible?
write('\33\[2J').
This is in no way specific to SICStus. It is the ANSI escape code and works in any ISO conforming system.
While SWI-Prolog provides a tty_clear predicate in its tty library, Sicstus doesn't seem to have a built-in alternative for this. But there is a simple workaround (for unix/linux, may not be that simple on windows): You can start the sicstus shell via rlwrap, which is a readline-wrapper for arbitrary shell commands. Besides the obvious benefit of the command history, this also means you can now use other shell functionality in sicstus, like the left/right arrow keys, home/end keys, Ctrl-k for deleting everything after the cursor, and Ctrl-l to clear the screen.
rlwrap is available as a package for many linux distributions, for windows you would need to use cygwin - this article describes how to setup rlwrap with powershell (for use with sqlplus in this case) so I guess powershell is a requirement too.
In summary, once you have rlwrap installed, simply start sicstus as rlwrap sicstus and use Ctrl-l to clear the screen.
I have spent some time looking through the documentation and I could not find a way to programmatically clear the console screen (in case this is possible, I am happy to be proven wrong). Alternatively, you might want to use SPIDER, that is a SICStus Prolog IDE: http://sicstus.sics.se/spider/ In Spider, the ordinary TopLevel interface has the option of clearing the current content of the console. Hope this helps.
If you're using swipl, then add this line in your user init file:
cls:-write('\33\[2J').
That should do it.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 12 months ago.
The community reviewed whether to reopen this question 12 months ago and left it closed:
Original close reason(s) were not resolved
Improve this question
I'm reasonably new to OS X, but I'm familiar with Vim from using it in various *nix systems. I've seen many people recommend running MacVim over Vim in the terminal. Can anyone tell me what differences there are between MacVim and regular Vim?
MacVim is just Vim. Anything you are used to do in Vim will work exactly the same way in MacVim.
MacVim is more integrated in the whole OS than Vim in the Terminal or even GVim in Linux, it follows a lot of Mac OS X's conventions.
If you work mainly with GUI apps (YummyFTP + GitX + Charles, for example) you may prefer MacVim.
If you work mainly with CLI apps (ssh + svn + tcpdump, for example) you may prefer vim in the terminal.
Entering and leaving one realm (CLI) for the other (GUI) and vice-versa can be "expensive".
I use both MacVim and Vim depending on the task and the context: if I'm in CLI-land I'll just type vim filename and if I'm in GUI-land I'll just invoke Quicksilver and launch MacVim.
When I switched from TextMate I kind of liked the fact that MacVim supported almost all of the regular shortcuts Mac users are accustomed to. I added some of my own, mimiking TextMate but, since I was working in multiple environments I forced my self to learn the vim way. Now I use both MacVim and Vim almost exactly the same way. Using one or the other is just a question of context for me.
Also, like El Isra said, the default vim (CLI) in OS X is slightly outdated. You may install an up-to-date version via MacPorts or you can install MacVim and add an alias to your .profile:
alias vim='/path/to/MacVim.app/Contents/MacOS/Vim'
to have the same vim in MacVim and Terminal.app.
Another difference is that many great colorschemes out there work out of the box in MacVim but look terrible in the Terminal.app which only supports 8 colors (+ highlights) but you can use iTerm — which can be set up to support 256 colors — instead of Terminal.
So… basically my advice is to just use both.
EDIT: I didn't try it but the latest version of Terminal.app (in 10.7) is supposed to support 256 colors. I'm still on 10.6.x at work so I'll still use iTerm2 for a while.
EDIT: An even better way to use MacVim's CLI executable in your shell is to move the mvim script bundled with MacVim somewhere in your $PATH and use this command:
$ mvim -v
EDIT: Yes, Terminal.app now supports 256 colors. So if you don't need iTerm2's advanced features you can safely use the default terminal emulator.
EDIT: See comment from #Luke Davis.
Old answer:
The one reason I have which made switching to MacVim worth it: Yank uses the system clipboard.
I can finally copy paste between MacVim on my terminal and the rest of my applications.
unfortunately, with "mvim -v", ALT plus arrow windows still does not work. I have not found any way to enable it :-(
It's all about the key bindings which one can simply achieve from .vimrc configurations.
As far as clipboard is concerned you can use :set clipboard unnamed and the yank from vim will go to system clipboard.
Anyways, whichever one you end up using I suggest using this vimrc config
, it contains a whole lot of plugins and bindings which will make your experience smooth.
I'm looking for something similar to Emacs shell.
I want to be able to select text easily in my terminal, be able to manipulate the output.
Unfortunately, emacs is not always an option. I can't figure out how to make a few things (e.g autocompletion) work the way it does in gnome-terminal and it is a bit of a pain on remote system.
I would rather not spend the time fixing/configuring Emacs unless there is a cool piece of software out there doing something similar to gnome-terminal + let's me manipulate the output without touching the bloody mouse.
Thanks for your help,
-hbt
I'm not sure I completely understand the question, but if you're looking for terminal emulation inside of Emacs, there are at least four options bundled with Emacs 22+ that offer varying levels of xterm-like capability:
term
ansi-term
shell
eshell
eshell, IMO, is the most departed from the tradtional "xterm" experience, but also offers the most buffer-like experience, and it is cross-platform, which is a huge win.
I think shell might be the sweet spot for you if you're looking for term-like behavior, while retaining the editing capabilities.
Finally, term and ansi-term are very term-like, and will behave almost exactly like a xterm/konsole/gnome-shell session.
One other note: if you want scrollback access, copying, pasting, etc. and you don't have Emacs available, I highly recommend learning and using GNU Screen.
You should try the Emacs terminal emulator term(or its colored version ansi-term). There are other terminal emulators for Emacs around, but this is the most popular(and the only one bundled with the default installation).
Looks like you want to look into readline on bash (or if available on your favourite shell). A quick google gives a few links here (including a cheatsheet).
I was also looking for some kind of shell like emacs, with support to some feature like emacs buffers for example. That would be great.
I just found this one: Terminator
Have a look:
http://www.makeuseof.com/tag/5-applications-to-change-the-way-you-work-with-linux-terminal/
I have a few of our senior QA engineers in town for a few days and I am in the process of prepping them for testing an app that we are porting to Linux and OS X. These guys are smart. While they are not programmers they do understand things like how to open memory dumps to find the function pointer, and write simple python to help automate their job. But they have always used windows, and are only familiar with the tools there.
So my question is: What would you teach them to help test a native application running on OS X or Linux?
A few ideas I had were:
Basics of the file system, where config files are (/etc) where log files are (/var/log)
How to use locate, find, grep and co.
Using gdb to examine coredumps
If they are not afraid of gdb and analyzing core dumps then they should definitely know about valgrind.
Knowing how to do system call tracing and library function call tracing is very helpful, too.
If they need to kill http://en.wikipedia.org/wiki/Kill_(command) a renegade process knowing about signals http://en.wikipedia.org/wiki/Signal_(computing) helps.
If they need to convert text files between Windows and Linux the tr command http://en.wikipedia.org/wiki/Tr_(Unix) is their friend.
If they need to download files wget is an easy to use commandline tool.
Overall a decent knowledge about the most commonly used Linux shell bash should be a fundamental requirement.
There is a (very basic) Windows to Linux: A Beginner's Guide that may help to overcome the initial hurdles. Some more articles are here.
Here's A beginner’s introduction to the GNU/Linux command line
First two things that come to mind
Learn the shell (sh, ksh, bash or whatever they are going to use)
Learn how to use an editor (vi/m, emacs, pico even?)
I would teach tham how to set ulimit so that core files can be created. I might also include information on basic signal numbers and what those might mean. You might in addition give them an overview of ftp to move files off to where they are more comfortable as well the basics of CR LF issues. I would explain to them the primary differences between UNIX and Windows (the slashes are different) . I would also consider setting up a samba share so that they can use the tools of their choice to edit files.
Teaching them how to redirect output and how to use tee is probably something they might benefit from. The basics of file permissions is a must. Explaining that ssh and telnet are available to access those remote boxes might help if telnet port is disabled. Finally I would teach them that removing a file has no undo feature as windows has.
You might consider explaining ps -ef as well as simple pipes and grep. I would show them how to background processes and maybe kill process with kill -9. Tools such as top, xload, and pstree might help them out.
I would teach them to use simple unix tools, such as time/ sed / grep / maybe even perl. Shell scripting and the "many simple commands" philosophy.
On the other side, learn how to use more complex tools such as
valgrind
gdb
strace
etrace
EDIT: Of course, some text editor (vim/emacs/mcedit/etc) is needed.