How do I update my PromptManager settings for IPython 5.0? - ipython

The lines
# Output prompt. '\#' will be transformed to the prompt number
c.PromptManager.out_template = '{color.Green}Out[{count}]{color.Green} : {color.LightGray}'
# Continuation prompt.
c.PromptManager.in2_template = '{color.Yellow} .\\D.{color.Green} : {color.LightGray}'
# If True (default), each prompt will be right-aligned with the preceding one.
c.PromptManager.justify = True
# Input prompt. '\#' will be transformed to the prompt number
c.PromptManager.in_template = '{color.Green}In [{count}]{color.LightGreen} : {color.DarkGray}'
in my ipython_config.py give
usr/local/lib/python2.7/site-packages/IPython/core/interactiveshell.py:440: UserWarning: As of IPython 5.0 `PromptManager` config will have no effect and has been replaced by TerminalInteractiveShell.prompts_class
warn('As of IPython 5.0 `PromptManager` config will have no effect'
but replacing PromptManager with TerminalInteractiveShell.prompts_class has no effect.
How do I update my PromptManager settings for IPython 5.0?

Related

python-language-server config file location

I'm trying to use flake8 as the default python linter using python-language-server on neovim v0.5.
python-lsp documentation says to set pylsp.configurationSources to ['flake8'], but doesn't specify which file to edit.
Where does the python-lsp-server config file reside?
According to flake8 documentation, the location of flake8 config varies based on systems, on Linux and Mac, it is ~/.config/flake8, and for Windows, it is $HOME\.flake8 ($HOME is like C:\\Users\sigmavirus24). The content should be in INI format:
[flake8]
max-line-length = 100
max-complexity = 30
ignore =
# missing whitespace around arithmetic operator
E226,
# line break before/after binary operator
W503,
W504,
# expected 1 blank line, found 0
E301,E302,
To suppress a single warning, it is also handy to add # noqa: F841-like (change the code to the actual code you want to use) comment string to suppress it.
Ref: https://jdhao.github.io/2020/11/05/pyls_flake8_setup/#config-location

How to remove blank line before prompt when I set fish_greating to null?

I want to remove the blank line before prompt when I open a new fish shell window.
I try to remove fish_greating use official FAQ.
➜ set fish_greeting
Here's my plugins.
vue-multiple-pages on  master [!] is 📦 v0.1.0 via ⬢ none
➜ fisher ls
edc/bass
FabioAntunes/fish-nvm
matchai/spacefish
It works. I remove the greating "Welcome to fish, the friendly interactive shell".
But, I got a blank line like this:
How to remove this blank line?
======updated======
This is is gif that I want to explain.
Thanks.
After a few hours of hard work, I found the answer.
It's the matchai/spacefish plugin which add new line to my prompt.
Here is the function
# Defined in /Users/liwei/.config/fish/functions/fish_prompt.fish # line 1
function fish_prompt
set -g sf_exit_code $status
set -g SPACEFISH_VERSION 2.6.0
# ------------------------------------------------------------------------------
# Configuration
# ------------------------------------------------------------------------------
__sf_util_set_default SPACEFISH_PROMPT_ADD_NEWLINE true
__sf_util_set_default SPACEFISH_PROMPT_FIRST_PREFIX_SHOW false
__sf_util_set_default SPACEFISH_PROMPT_PREFIXES_SHOW true
__sf_util_set_default SPACEFISH_PROMPT_SUFFIXES_SHOW true
__sf_util_set_default SPACEFISH_PROMPT_DEFAULT_PREFIX "via "
__sf_util_set_default SPACEFISH_PROMPT_DEFAULT_SUFFIX " "
__sf_util_set_default SPACEFISH_PROMPT_ORDER time user dir host git package node ruby golang php rust haskell julia elixir docker aws venv conda pyenv dotnet kubecontext exec_time line_sep battery vi_mode jobs exit_code char
# ------------------------------------------------------------------------------
# Sections
# ------------------------------------------------------------------------------
# Keep track of whether the prompt has already been opened
set -g sf_prompt_opened $SPACEFISH_PROMPT_FIRST_PREFIX_SHOW
if test "$SPACEFISH_PROMPT_ADD_NEWLINE" = "true"
echo
end
for i in $SPACEFISH_PROMPT_ORDER
eval __sf_section_$i
end
set_color normal
end
Just set SPACEFISH_PROMPT_ADD_NEWLINE to false,
add this line to your config.fish and solve the problem.
set SPACEFISH_PROMPT_ADD_NEWLINE false
Thanks to all.

How to save ipython alias forever?

I am a bit confused on how to save ipython alias so that everytime i open a ipython session(after saving alias firstly ) and use the alias command directly(at the point,you should not input the alias again ).
For example,when use ipython in linux(or windows) ,i would use vi rather than !vi a file .
vi fileneme
!vi filename
To generate the default configuration files ipython_config.py in your IPython directory under profile_default :
$ ipython profile create
Find ipython_config.py in linux/windows
#use find command in linux
find / -name ipython_config.py
#in window,you can use all kinds of tools to search .
#in commands line,you can use
ipython locate profile.
#in the directory,you can get it
Edit the ipython_config.py file to add the fellowing content
c = get_config()
c.TerminalIPythonApp.display_banner = True
c.InteractiveShellApp.log_level = 20
c.InteractiveShellApp.extensions = []
c.InteractiveShellApp.exec_lines = []
c.InteractiveShellApp.exec_files = ['mycode.py']#load Module when open ipython
c.InteractiveShell.autoindent = True
c.InteractiveShell.colors = 'LightBG'#ipython console color
c.InteractiveShell.confirm_exit = False
c.InteractiveShell.editor = 'vim'#you can change your favorite editor
c.InteractiveShell.xmode = 'Context'
c.PrefilterManager.multi_line_specials = True
#you can add your alias in the fellowing list
c.AliasManager.user_aliases = [('vi','vim'),('py','python'),('git','git'),]#i add git ,vim python .i really dislike "!"
Save the file and exit and get it
thx#jack yang
1.
emacs ~/.ipython/profile_default/python_config.py
2.in the end wirte down
c.AliasManager.user_aliases = [('e', 'emacsclient -t')]
3.exit and restart ipython

IPython qtconsole ignores PromptManager change

I edited ipython_qtconsole_config.py to include a timestamp:
import datetime
c = get_config()
c.PromptManager.in_template = '%s In [\\#]: ' % datetime.datetime.now().strftime("%H:%M:%S")
When I type config PromptManager in the shell I see that my change was made, however no timestamp is displayed. How can I fix this issue?
The qtconsole prompt doesn't support most of what the regular IPython prompt does (which is an open issue). The configurable is also different.
The default value:
c.IPythonWidget.in_prompt = 'In [<span class="in-prompt-number">%i</span>]: '
You can change it with:
c.IPythonWidget.in_prompt = '<b><i>My Prompt </i>[%i]: </b>'
When the issue is addressed, it should behave exactly as you expect.

Log IPython output?

Is there any way to make IPython's logging capability include output as well as input?
This is what a log file looks like currently:
#!/usr/bin/env python
# 2012-08-06.py
# IPython automatic logging file
# 12:02
# =================================
print "test"
I'd like to have one more line show up:
#!/usr/bin/env python
# 2012-08-06.py
# IPython automatic logging file
# 12:02
# =================================
print "test"
# test
(the # is because I assume that is needed to prevent breaking IPython's logplay feature)
I suppose this is possible using IPython notebooks, but on at least one machine I need this for, I'm limited to ipython 0.10.2.
EDIT: I'd like to know how to set this up automatically, i.e. within the configuration file. Right now my config looks like
from time import strftime
import os
logfilename = strftime('ipython_log_%Y-%m-%d')+".py"
logfilepath = "%s/%s" % (os.getcwd(),logfilename)
file_handle = open(logfilepath,'a')
file_handle.write('########################################################\n')
out_str = '# Started Logging At: '+ strftime('%Y-%m-%d %H:%M:%S\n')
file_handle.write(out_str)
file_handle.write('########################################################\n')
file_handle.close()
c.TerminalInteractiveShell.logappend = logfilepath
c.TerminalInteractiveShell.logstart = True
but specifying c.TerminalInteractiveShell.log_output = True seems to have no affect
There's the -o option for %logstart:
-o: log also IPython's output. In this mode, all commands which
generate an Out[NN] prompt are recorded to the logfile, right after
their corresponding input line. The output lines are always
prepended with a '#[Out]# ' marker, so that the log remains valid
Python code.
ADDENDUM: If you are in an interactive ipython session for which logging has already been started, you must first stop logging and then restart:
In [1]: %logstop
In [2]: %logstart -o
Activating auto-logging. Current session state plus future input saved.
Filename : ./ipython.py
Mode : backup
Output logging : True
Raw input log : False
Timestamping : False
State : active
Observe that, after the restart, "Output Logging" is now "True".