recentpopularlog in

kme : repl   89

« earlier  
savehistory function | R Documentation
The "Example" section is jacked up, and I can't tell what that's supposed to look like; try https://stackoverflow.com/a/16738440 (answer from Hadley Wickham) instead.

Maybe the version of R that we have on the cluster didn't build against the readline library or something, and *that's* why up/down arrows don't recall the history.
r  history  repl  annoyance  maybesolution 
june 2019 by kme
r - Saving and loading history automatically - Stack Overflow
In my ~/.profile I have:
<code class="language-bash">export R_HISTFILE=~/.Rhistory</code>

In my ~/.Rprofile I have:
<code class="language-R">if (interactive()) {
.Last <- function() try(savehistory("~/.Rhistory"))
}</code>

and that works for me (although it doesn't work very well if you have multiple R sessions open). I also have
<code class="language-bash">alias R='R --no-save --no-restore-data --quiet'</code>

in my profile which eliminates the questions on close.
r  repl  history  configfile  annoyance  solution  fuckina 
june 2019 by kme
readline - python tab completion Mac OSX 10.7 (Lion) - Stack Overflow | https://stackoverflow.com/
Putting this in a ~/.pythonrc works for Python >= 3. Python 2.7.x seems to require that you set PYTHONSTARTUP=~/.pythonrc in your login scripts.

<code class="language-python">import readline
import rlcompleter
if 'libedit' in readline.__doc__:
readline.parse_and_bind("bind ^I rl_complete")
else:
readline.parse_and_bind("tab: complete")</code>
python  macos  osx  repl  tabcompletion  autocompletion  annoyance  configfile  essential  movein 
march 2019 by kme
Autocompletion for your python shell|console|interpreter | http://blog.e-shell.org/
You really do need to set PYTHONSTARTUP in your login scripts.
So, all you have to do is, first, add this two lines to a file, for example, called .pythonrc in your home:
<code class="language-bash">cat ~/.pythonrc
# import rlcompleter, readline
# readline.parse_and_bind('tab:complete')
</code>

Second, add the PYTHONSTARTUP variable to your shell profile file. If you are using csh, tcsh or similar shells, this will do it:
<code class="language-bash">echo "setenv PYTHONSTARTUP ~/.pythonrc" >> ~/.cshrc</code>

If your shell is sh, bash, ksh or similars, this will do it:
<code class="language-bash">echo "export PYTHONSTARTUP=~/.pythonrc" >> ~/.profile</code>


On macOS, where the system Python is probably compiled against libedit instead of readline, you need to do this instead:

<code class="language-python">import readline
import rlcompleter
if 'libedit' in readline.__doc__:
readline.parse_and_bind("bind ^I rl_complete")
else:
readline.parse_and_bind("tab: complete")</code>
python  repl  autocompletion  tabcompletion  configfile  dotfile  solution 
march 2019 by kme
Enhanced Tk Console: tkcon | http://tkcon.sourceforge.net/
Minimal ~/.tkconrc for a decent font and window size:

<code class="language-tcl">
tkcon font mononoki 14
set ::tkcon::OPT(cols) 100
set ::tkcon::OPT(rows) 25
</code>
tcl  tk  console  cli  repl  history  readline 
january 2019 by kme
Wirble: Tab-Completion and Syntax Coloring for irb | http://www.rubyinside.com/
If you haven't got tab-completion and syntax coloring in your irb, you owe it to yourself to follow these instructions right away (should work for Linux, OS X, and Cygwin users). First, install the Wirble gem:
<code class="language-bash">sudo gem install -y wirble</code>

Next, create or edit a file called .irbrc in your home folder (~/.irbrc), and make sure these lines are included there:
<code class="language-ruby">require 'rubygems'
require 'wirble'
Wirble.init
Wirble.colorize</code>
ruby  repl  irb  syntaxhighlighting  fuckina  solution 
may 2018 by kme
ruby - Why can't IRB locate the file to "require"? - Stack Overflow | https://stackoverflow.com/
Try require './test'

I think newer versions of Ruby removed the current directory from the Ruby path.

Edit: Also, check out the answer to "Why isn't current directory on my Ruby path?" for an explanation why require_relative doesn't work in irb.
ruby  irb  repl  library  devel  errormessage  solution 
october 2017 by kme
Java REPL
The repl.it REPL wants you to wrap everything in classes. It's not so great.
java  repl  devel  solution 
april 2017 by kme
Built-in magic commands — IPython 3.2.1 documentation
Solution: give '-n' option to '%timeit' to control the number of loops. IPython tries successive powers of ten until the result takes at least 0.2 seconds.

e.g., %timeit -n10 function(arg1, arg2)
ipython  python  repl  magic  solution 
january 2017 by kme
GitHub - nteract/nteract: Interactive literate coding notebook!
The second command really *is* necessary:
At least for now, we need the python 3 kernel installed when hacking on nteract:

python3 -m pip install ipykernel
python3 -m ipykernel install --user
python  ipython  ipythonnotebook  jupyter  repl  mac  osx  gui 
december 2016 by kme
xenoterracide: Making re.pl usable
Update 2017-10-25: Finally found out how to keep Ctrl+C from terminating the REPL--add the "Interrupt" plugin.

You will probably need to install Sys::SigAction, because that doesn't seem to be pulled in as a dependency of Devel::REPL.

On a Mac, you will need to install Term::ReadLine::Perl.

<code class="language-perl">
# put this in $HOME/.re.pl/repl.rc
use 5.012;
use warnings;

load_plugin qw(
Colors
Completion
CompletionDriver::INC
CompletionDriver::LexEnv
CompletionDriver::Keywords
CompletionDriver::Methods
DumpHistory
History
LexEnv
ReadLineHistory
Interrupt
);</code>
perl  repl  config  configfile  movein  syntaxhighlighting  history  completion  solution  fuckina  essential 
december 2016 by kme
GitHub - jonathanslenders/ptpython: A better Python REPL
Don't prompt to exit (put in ~/.ptpython/config.py):

<code class="language-python"># Source: https://github.com/jonathanslenders/ptpython/blob/master/examples/ptpython_config/config.py
def configure(repl):
# Ask for confirmation on exit.
repl.confirm_exit = False</code>

Sample config is here: https://github.com/jonathanslenders/ptpython/blob/master/examples/ptpython_config/config.py
python  essential  movein  ptpython  annoyance  configfile  repl 
december 2016 by kme
How do I unload (reload) a Python module? - Stack Overflow [http://stackoverflow.com/]
You can reload a module when it has already been imported by using the reload builtin function in Python 2:

python  interactivemode  repl  devel  modules  tipsandtricks 
july 2016 by kme
13. Interactive Input Editing and History Substitution — Python 2.7.12 documentation
You should probably also add 'Tab: complete' to your ~/.inputrc.
# Add auto-completion and a stored history file of commands to your Python
# interactive interpreter. Requires Python 2.0+, readline. Autocomplete is
# bound to the Esc key by default (you can change it - see readline docs).
#
# Store the file in ~/.pystartup, and set an environment variable to point
# to it: "export PYTHONSTARTUP=~/.pystartup" in bash.

import atexit
import os
import readline
import rlcompleter

historyPath = os.path.expanduser("~/.pyhistory")

def save_history(historyPath=historyPath):
import readline
readline.write_history_file(historyPath)

if os.path.exists(historyPath):
readline.read_history_file(historyPath)

atexit.register(save_history)
del os, atexit, readline, rlcompleter, save_history, historyPath
python  interactivemode  readline  history  configfile  repl  fuckina  solution 
july 2016 by kme
Make the history searchable · Issue #68 · borisrepl/boris

Does this actually require a PR or change to boris? My version of PHP is compiled with libedit, and when I add

# Support reverse history search for libedit.
bind "^R" em-inc-search-prev

to my .editrc file, I can do reverse history searches by pressing ctrl-r.
php  boris  repl  readline  libedit  annoyance  solution  workaround 
june 2016 by kme
php - install php5 with readline support on debian wheezy - Unix & Linux Stack Exchange
Couldn't find php5-readline on this system, and didn't want to mess with adding "unofficial" software sources. Facebook's 'phpsh' seems to work okay without any extra dependencies; just remeber to set PYTHONPATH to wherever the libraries ended up, otherwise you'll get:
Traceback (most recent call last):
File "./phpsh", line 4, in <module>
from phpsh import PhpshState, PhpMultiliner, do_sugar, line_encode, __version__
ImportError: No module named phpsh

However an alternative equivalent solution is facebook's phpsh. this is an interactive php shell and it has some nice features such as tabtab completion for function names and syntax highlighting for notices.
php  debian  readline  repl  webdevel  solution 
february 2016 by kme
erichs/composure · GitHub
Ach so! 'typeset' is just an alias for 'declare'.
Retrieve your metadata later by calling 'metafor ()':

typeset -f foo | metafor about # displays:
perform mad script-foo
unix  shellscripting  repl  scripting  cli  bash  utility  software 
september 2015 by kme
cosmin/IClojure · GitHub
Leiningen 2

Add [lein-iclojure "1.2"] to the :user profile in ~/.lein/profiles.clj. Here is an example

{:user {:plugins [ [lein-iclojure "1.2"] ]}}
clojure  repl 
august 2015 by kme
borisrepl/boris
Requires (at least) 'php-process' on CentOS 6 (source: http://www.linuxquestions.org/questions/linux-server-73/how-to-get-posix-functions-installed-in-php-on-rhel-6-3-a-4175435197/) and 'php56-posix' and 'php56-pcntl' from MacPorts for OS X.
mac  osx  centos  php  repl  webdevel  solution 
june 2015 by kme
Guile Reference Manual: Loading Readline Support
Add these to ~/.guile

(use-modules (ice-9 readline))
(activate-readline)
guile  readline  history  commandline  repl  solution 
february 2015 by kme
shell - Perl: console / command-line tool for interactive code evaluation and testing - Stack Overflow
If your problem with perl -d -e 1 is that it lacks command line history, then you should install Term::ReadLine::Perl which the debugger will use when installed.
perl  repl  missinglibrary  devel  solution 
september 2014 by kme
Devel::REPL - A modern perl interactive shell - metacpan.org | https://metacpan.org/::REPL
Try this:
cpanm install Devel::REPL Devel::REPL::Plugin::ReadLineHistory Term::ReadLine::Perl

then add the code at https://pinboard.in/u:kme/b:25359e5087f4 into $HOME/.re.pl/repl.rc.

Requires Term::ReadLine::Perl in order for command history to really work at all (cpanm Term::ReadLine::Perl).
perl  module  devel  repl  solution  essential  movein 
september 2014 by kme
Ruby irb Command History Mac Developer Tips

# ~/.irbrc
require 'irb/completion'
require 'irb/ext/save-history'

ARGV.concat [ "--readline",
"--prompt-mode",
"simple" ]

# 25 entries in the list
IRB.conf[:SAVE_HISTORY] = 25

# Store results in home directory with specified file name
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-history"
irb  ruby  repl  configfile  rcfile  comandline  annoyance  solution  fuckina 
july 2014 by kme
java - Run class in Jar file - Stack Overflow [http://stackoverflow.com/]
Solution to how to run the BeanShell bsh.Interpreter class from within the .jar file:

java -cp myjar.jar com.mypackage.myClass
java  repl  beanshell  programming  cli  commandline  solution 
september 2013 by kme
« earlier      
per page:    204080120160

Copy this bookmark:





to read