Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kdheepak/startup.jl


https://github.com/kdheepak/startup.jl

Last synced: 23 days ago
JSON representation

Awesome Lists containing this project

README

        

# Startup

[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://kdheepak.github.io/Startup.jl/stable/)
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://kdheepak.github.io/Startup.jl/dev/)
[![Build Status](https://github.com/kdheepak/Startup.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/kdheepak/Startup.jl/actions/workflows/CI.yml?query=branch%3Amain)

## Julia tips and tricks

Based on [@mroavi's configuration](https://github.com/mroavi/dotfiles/blob/2d1f6d05515153b3616f5384faf85e2d406a6e26/julia/.julia/config/tips-and-tricks.md).

### Open file in stacktrace

In the REPL, enter the stacktrace number followed by Ctrl+q

```julia
julia> map("hola")
Stacktrace:
[1] map(f::String)
@ Base ./abstractarray.jl:2859
[2] top-level scope
@ REPL[15]:1
julia> 1
```

### List of Handy Macros

```julia
@edit
@debug [key=value | value ...]
```

To enable @debug messages, you need to set the JULIA_DEBUG environment var:

```julia
julia> ENV["JULIA_DEBUG"] = "all"
```

### View Code at different Compiling Stages

```julia
@code_lowered
@code_typed
@code_llvm
@code_native

@code_warntype
```

### Methods Available

Write a function in the REPL with the opening parenthesis and type Tab

Another option is to use the `@which` macro:

```julia
@which
```

You can also query Julia to output all methods that take a certain type of
argument with:

```julia
methodswith(typ[, module or function]; supertypes::Bool=false])
```

### REPL History

Type the beginning of a command and type Ctrl+p to browse
through all commands in history that begin with the same chars. For example:

```julia
julia> ENV
```

completes to:

```julia
julia> ENV["JULIA_DEBUG"] = "all"
```

With OhMyREPL, type Ctrl+R in the REPL to start FZF to
filter the REPL History

### REPL apropos

Search available docstrings for entries containing pattern. When pattern is a
string, case is ignored. Results are printed to io.

```julia
apropos([io::IO=stdout], pattern::Union{AbstractString,Regex})
```

### Debugger

```
julia> using Debugger # import the julia debugger
julia> @enter # run in debugger mode
debug> ? # list the help to see all debugger available cmds
debug> ` # go to julia mode keeping the backtrace (backspace to leave)
|julia> print(x) # print the content of `x`
|julia> x = 2 # assign the value 2 to `x`
```

### Search Documentation

Search available docstrings for entries containing `pattern` with the `apropos`
function. See ?apropos

REPL help mode understands regex, e.g., enter r"^has" to get all methods
starting with "has".

### Disabling auto-indentation of code in Julia REPL

Source:

Consists of overwriting `REPL.LineEdit.options` method to make sure that we
always use `REPL.GlobalOptions` with auto-indentation disabled.

Useful when using **onthefly** for live-coding presentations.

```julia
import REPL
REPL.GlobalOptions.auto_indent = false
REPL.LineEdit.options(s::REPL.LineEdit.PromptState) = REPL.GlobalOptions
```