mrjones2014 / ctrlg

A command line context switcher, written in Rust :crab:
https://crates.io/crates/ctrlg
MIT License
30 stars 1 forks source link

[Bug]: No graphics appear when ctrlg is opened #13

Closed greembow closed 2 years ago

greembow commented 2 years ago

Similar Issues

Description

out https://user-images.githubusercontent.com/71287827/146962890-43456a8b-ac65-449b-b56e-0e5470cff96b.mp4

I'm not sure if the GIF will load properly, but basically, when I press ctrl-g, the ctrlg UI appears, but nothing ever happens after that. Maybe I'm using it wrong?

Operating System + Version

Arch Linux 5.15.7-arch1-1

Shell + Version

zsh 5.8 (x86_64-pc-linux-gnu)

Minimal Configuration to Reproduce

HISTFILE=~/.histfile
HISTSIZE=10000
SAVEHIST=10000
setopt autocd beep extendedglob nomatch notify correct_all

# Keybind snippet from https://bbs.archlinux.org/viewtopic.php?id=26110
autoload zkbd
[[ ! -f ${ZDOTDIR:-$HOME}/.zkbd/$TERM-$VENDOR-$OSTYPE ]] && zkbd
source ${ZDOTDIR:-$HOME}/.zkbd/$TERM-$VENDOR-$OSTYPE

[[ -n ${key[Backspace]} ]] && bindkey "${key[Backspace]}" backward-delete-char
[[ -n ${key[Insert]} ]] && bindkey "${key[Insert]}" overwrite-mode
[[ -n ${key[Home]} ]] && bindkey "${key[Home]}" beginning-of-line
[[ -n ${key[PageUp]} ]] && bindkey "${key[PageUp]}" up-line-or-history
[[ -n ${key[Delete]} ]] && bindkey "${key[Delete]}" delete-char
[[ -n ${key[End]} ]] && bindkey "${key[End]}" end-of-line
[[ -n ${key[PageDown]} ]] && bindkey "${key[PageDown]}" down-line-or-history
[[ -n ${key[Up]} ]] && bindkey "${key[Up]}" up-line-or-search
[[ -n ${key[Left]} ]] && bindkey "${key[Left]}" backward-char
[[ -n ${key[Down]} ]] && bindkey "${key[Down]}" down-line-or-search
[[ -n ${key[Right]} ]] && bindkey "${key[Right]}" forward-char

# Load version control information
autoload -Uz vcs_info
precmd() { vcs_info }

# Format the vcs_info_msg_0_ variable
zstyle ':vcs_info:git:*' formats 'on %F{4}branch %F{6}%b '

# Function for gathering the last exit code and setting the right prompt to it
function check_last_exit_code() {
  local LAST_EXIT_CODE=$?
  if [[ $LAST_EXIT_CODE -ne 0 ]]; then
    local EXIT_CODE_PROMPT=' '
    EXIT_CODE_PROMPT+="%B%F{5}-%F{1}$LAST_EXIT_CODE%F{5}-%F{15}%b"
    echo "$EXIT_CODE_PROMPT"
  fi
}

# Setup the left prompt, including VCS info
setopt PROMPT_SUBST
PROMPT='%F{9}%n %F{15}in %F{3}${PWD/#$HOME/~} %F{15}${vcs_info_msg_0_}%F{2}%#%F{15} > '
RPROMPT='$(check_last_exit_code)'

# Setup some basic aliases, and add color where possible
alias ...="cd ../.."
alias ....="cd ../../.."
alias ls='ls --color'
alias la='ls -lah --color'
alias grep='grep --color'
alias ip='ip -c'
alias udb='sudo updatedb'
alias clr='clear'
alias rcd='ranger --choosedir=$HOME/.rangerdir; LASTDIR=`cat $HOME/.rangerdir`; cd "$LASTDIR"'
alias spotify-dl='spotify_dl'
alias vi='nvim'
alias vim='nvim'

# Run afetch if in terminal
[[ "$(cat /proc/$PPID/comm)" =~ "(kitty)" ]] && afetch
[[ "$(cat /proc/$PPID/comm)" =~ "(kitty)" ]] && export TERM="kitty"

### Added by Zinit's installer
if [[ ! -f $HOME/.local/share/zinit/zinit.git/zinit.zsh ]]; then
    print -P "%F{33} %F{220}Installing %F{33}ZDHARMA-CONTINUUM%F{220} Initiative Plugin Manager (%F{33}zdharma-continuum/zinit%F{220})…%f"
    command mkdir -p "$HOME/.local/share/zinit" && command chmod g-rwX "$HOME/.local/share/zinit"
    command git clone https://github.com/zdharma-continuum/zinit "$HOME/.local/share/zinit/zinit.git" && \
        print -P "%F{33} %F{34}Installation successful.%f%b" || \
        print -P "%F{160} The clone has failed.%f%b"
fi

source "$HOME/.local/share/zinit/zinit.git/zinit.zsh"
autoload -Uz _zinit
(( ${+_comps} )) && _comps[zinit]=_zinit

# Load a few important annexes, without Turbo
# (this is currently required for annexes)
zinit light-mode for \
    zdharma-continuum/zinit-annex-as-monitor \
    zdharma-continuum/zinit-annex-bin-gem-node \
    zdharma-continuum/zinit-annex-patch-dl \
    zdharma-continuum/zinit-annex-rust

### End of Zinit's installer chunk

zinit light zsh-users/zsh-syntax-highlighting
zinit light zsh-users/zsh-autosuggestions
zinit light zsh-users/zsh-history-substring-search
eval "$(ctrlg init zsh)"

I'm sorry that this is probably the worst .zshrc you've ever seen. :(

Additional Details

Lenovo ThinkPad X1 Yoga 4th Intel i7 10510U 16gb DDR4 Intel Integrated Graphics

mrjones2014 commented 2 years ago

@greembow Hey, thanks for filing an issue! By default, ctrlg searches ~/git/, if you want to search a different directory, or set of directories, you'll need to specify in the config file at ~/.config/ctrlg/config.yml. Could that be your issue?

I should probably make this a little bit more clear in the README.md. There's also an issue right now where it will only check for config.yml and not config.yaml in the ~/.config/ctrlg/ directory. I can get that issue fixed pretty quickly.

greembow commented 2 years ago

@mrjones2014 Thanks! I'm very stupid then haha. I tried following your instructions and I'm now getting a panic upon opening ctrlg.

greembow in ~ % > thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: invalid type: sequence, expected a boolean for key `preview_fallback_exa` in .config/ctrlg/config.yml', /home/greembow/.cargo/registry/src/github.com-1ecc6299db9ec823/ctrlg-0.1.0/src/settings.rs:89:76
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

greembow in ~ % > export RUST_BACKTRACE=1
greembow in ~ % > thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: invalid type: sequence, expected a boolean for key `preview_fallback_exa` in .config/ctrlg/config.yml', /home/greembow/.cargo/registry/src/github.com-1ecc6299db9ec823/ctrlg-0.1.0/src/settings.rs:89:76
stack backtrace:
   0: rust_begin_unwind
             at /rustc/00d5e42e776da900049fe19087bc9b0057ec70cd/library/std/src/panicking.rs:495:5
   1: core::panicking::panic_fmt
             at /rustc/00d5e42e776da900049fe19087bc9b0057ec70cd/library/core/src/panicking.rs:107:14
   2: core::result::unwrap_failed
             at /rustc/00d5e42e776da900049fe19087bc9b0057ec70cd/library/core/src/result.rs:1617:5
   3: std::sync::once::Once::call_once::{{closure}}
   4: std::sync::once::Once::call_inner
             at /rustc/00d5e42e776da900049fe19087bc9b0057ec70cd/library/std/src/sync/once.rs:419:21
   5: ctrlg::settings::Settings::merge_find_args
   6: ctrlg::commands::CtrlgCommand::run
   7: ctrlg::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

greembow in ~ % > export RUST_BACKTRACE=full
greembow in ~ % > thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: invalid type: sequence, expected a boolean for key `preview_fallback_exa` in .config/ctrlg/config.yml', /home/greembow/.cargo/registry/src/github.com-1ecc6299db9ec823/ctrlg-0.1.0/src/settings.rs:89:76
stack backtrace:
   0:     0x55eabcdd322c - std::backtrace_rs::backtrace::libunwind::trace::hc6c3491277866fea
                               at /rustc/00d5e42e776da900049fe19087bc9b0057ec70cd/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x55eabcdd322c - std::backtrace_rs::backtrace::trace_unsynchronized::h4524f073368a5b13
                               at /rustc/00d5e42e776da900049fe19087bc9b0057ec70cd/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x55eabcdd322c - std::sys_common::backtrace::_print_fmt::h0d0cace6159902af
                               at /rustc/00d5e42e776da900049fe19087bc9b0057ec70cd/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x55eabcdd322c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h3e6af6f05919a7fc
                               at /rustc/00d5e42e776da900049fe19087bc9b0057ec70cd/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x55eabcdf879c - core::fmt::write::h72801a82c94e6ff1
                               at /rustc/00d5e42e776da900049fe19087bc9b0057ec70cd/library/core/src/fmt/mod.rs:1163:17
   5:     0x55eabcdce4e5 - std::io::Write::write_fmt::ha4f5d34aaccbac84
                               at /rustc/00d5e42e776da900049fe19087bc9b0057ec70cd/library/std/src/io/mod.rs:1696:15
   6:     0x55eabcdd4cd0 - std::sys_common::backtrace::_print::heed69f5ce9a8e189
                               at /rustc/00d5e42e776da900049fe19087bc9b0057ec70cd/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x55eabcdd4cd0 - std::sys_common::backtrace::print::h5f3918bd80c09252
                               at /rustc/00d5e42e776da900049fe19087bc9b0057ec70cd/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x55eabcdd4cd0 - std::panicking::default_hook::{{closure}}::h5af30648530eb3d0
                               at /rustc/00d5e42e776da900049fe19087bc9b0057ec70cd/library/std/src/panicking.rs:210:50
   9:     0x55eabcdd487b - std::panicking::default_hook::he88d5fb1ba1b4c19
                               at /rustc/00d5e42e776da900049fe19087bc9b0057ec70cd/library/std/src/panicking.rs:227:9
  10:     0x55eabcdd5384 - std::panicking::rust_panic_with_hook::h01febc308b2b313b
                               at /rustc/00d5e42e776da900049fe19087bc9b0057ec70cd/library/std/src/panicking.rs:602:17
  11:     0x55eabcdd4e60 - std::panicking::begin_panic_handler::{{closure}}::h24a6d13f5560b71f
                               at /rustc/00d5e42e776da900049fe19087bc9b0057ec70cd/library/std/src/panicking.rs:499:13
  12:     0x55eabcdd36d4 - std::sys_common::backtrace::__rust_end_short_backtrace::h3e2917f0da9fbc5c
                               at /rustc/00d5e42e776da900049fe19087bc9b0057ec70cd/library/std/src/sys_common/backtrace.rs:139:18
  13:     0x55eabcdd4dc9 - rust_begin_unwind
                               at /rustc/00d5e42e776da900049fe19087bc9b0057ec70cd/library/std/src/panicking.rs:495:5
  14:     0x55eabcb98561 - core::panicking::panic_fmt::h7b8580d81fcbbacd
                               at /rustc/00d5e42e776da900049fe19087bc9b0057ec70cd/library/core/src/panicking.rs:107:14
  15:     0x55eabcb98653 - core::result::unwrap_failed::h885d3f7beb571353
                               at /rustc/00d5e42e776da900049fe19087bc9b0057ec70cd/library/core/src/result.rs:1617:5
  16:     0x55eabcba2e5f - std::sync::once::Once::call_once::{{closure}}::hd04e9a03b3296881
  17:     0x55eabcb975fe - std::sync::once::Once::call_inner::h911bb651f19e1e50
                               at /rustc/00d5e42e776da900049fe19087bc9b0057ec70cd/library/std/src/sync/once.rs:419:21
  18:     0x55eabcb9c4f3 - ctrlg::settings::Settings::merge_find_args::h0664ed532e72bdd4
  19:     0x55eabcba81e4 - ctrlg::commands::CtrlgCommand::run::h0ba0b9b7aa3cb6ef
  20:     0x55eabcba29b7 - ctrlg::main::h40b85dff1308e2ff
  21:     0x55eabcb9e3a3 - std::sys_common::backtrace::__rust_begin_short_backtrace::hb2eb6c6d024fcf17
  22:     0x55eabcba2b19 - std::rt::lang_start::{{closure}}::h02c7a39f50ba527e
  23:     0x55eabcdd2ac1 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h6743157f0325d450
                               at /rustc/00d5e42e776da900049fe19087bc9b0057ec70cd/library/core/src/ops/function.rs:259:13
  24:     0x55eabcdd2ac1 - std::panicking::try::do_call::hc65378359d322d46
                               at /rustc/00d5e42e776da900049fe19087bc9b0057ec70cd/library/std/src/panicking.rs:403:40
  25:     0x55eabcdd2ac1 - std::panicking::try::h52b83ca0140efb28
                               at /rustc/00d5e42e776da900049fe19087bc9b0057ec70cd/library/std/src/panicking.rs:367:19
  26:     0x55eabcdd2ac1 - std::panic::catch_unwind::h0ba25f4b0d3448dc
                               at /rustc/00d5e42e776da900049fe19087bc9b0057ec70cd/library/std/src/panic.rs:133:14
  27:     0x55eabcdd2ac1 - std::rt::lang_start_internal::{{closure}}::ha65f28100c5ad390
                               at /rustc/00d5e42e776da900049fe19087bc9b0057ec70cd/library/std/src/rt.rs:128:48
  28:     0x55eabcdd2ac1 - std::panicking::try::do_call::h5db5edfaf5b749d9
                               at /rustc/00d5e42e776da900049fe19087bc9b0057ec70cd/library/std/src/panicking.rs:403:40
  29:     0x55eabcdd2ac1 - std::panicking::try::h62409771d6cd0419
                               at /rustc/00d5e42e776da900049fe19087bc9b0057ec70cd/library/std/src/panicking.rs:367:19
  30:     0x55eabcdd2ac1 - std::panic::catch_unwind::h386261fb8f018fab
                               at /rustc/00d5e42e776da900049fe19087bc9b0057ec70cd/library/std/src/panic.rs:133:14
  31:     0x55eabcdd2ac1 - std::rt::lang_start_internal::h699f3530566c1833
                               at /rustc/00d5e42e776da900049fe19087bc9b0057ec70cd/library/std/src/rt.rs:128:20
  32:     0x55eabcba2a22 - main
  33:     0x7f2df9df7b25 - __libc_start_main
  34:     0x55eabcb98cfe - _start
  35:                0x0 - <unknown>

If it matters. I get an exitcode of 130.

Config file:

# configure what directories to list in the fuzzy finder
# can be any list of globbing patterns, will only show directories
# not files
search_dirs:
  - "~/Documents/Programming/*"
# globbing patterns of files to find for use as preview
# see below for more details on previews
preview_files:
  - "README.*"
# enable or disable the preview window
previews: true
# force using or not using `bat` for previews
preview_with_bat: [true if `bat` is installed, false otherwise]
# force using or not using `exa` for preview fallback when no
# matching `preview_files` are found
preview_fallback_exa: [true if `exa` is installed, false otherwise]
mrjones2014 commented 2 years ago

This is because it's expecting preview_with_bat and preview_fallback_exa to be boolean values (or not exist). The [true if exa is installed, false otherwise] is just meant to represent the fact that if exa is installed, it will be used by default.

Though you do bring up a good issue -- the documentation surrounding this needs to be improved.

mrjones2014 commented 2 years ago

Also as a note, previews is true by default, and preview_files is - "README.*" by default -- search_dirs is the only one you have there that isn't the default value, so you can exclude the other values unless you want to customize them.

mrjones2014 commented 2 years ago

I could also make it so that there's some sort of message printed if no directories are found.

greembow commented 2 years ago

Oh lord. I can't believe that after working with YAML for 3+ years that I didn't notice that. facepalm It's working great now! Awesome tool and I can't wait for more features if that ends up happening!

greembow commented 2 years ago

I could also make it so that there's some sort of message printed if no directories are found.

I think that would be a good solution.

mrjones2014 commented 2 years ago

I'll make a PR for this issue to print that error.

mrjones2014 commented 2 years ago

I can't wait for more features if that ends up happening!

Feel free to file a feature request if you have ideas :)

mrjones2014 commented 2 years ago

This will be released as 0.1.1 as soon as this job succeeds: https://github.com/mrjones2014/ctrlg/actions/runs/1607959122

mrjones2014 commented 2 years ago

whoops forgot to bump the version 😅 I've published it manually.