withfig / fig

Public issue tracker for Fig.
https://fig.io
MIT License
2.04k stars 63 forks source link

Error when starting terminal #1806

Open bmichotte opened 2 years ago

bmichotte commented 2 years ago

Description:

When I open my terminal (iTerm, Hyper), I have the following error

~/.config/fish/conf.d/99_fig_post.fish (line 2): Missing end to balance this if statement
if test -z "$FIG_DOTFILES_SOURCED"
^
from sourcing file ~/.config/fish/conf.d/99_fig_post.fish
    called on line 246 of file /usr/local/Cellar/fish/3.5.1/share/fish/config.fish
from sourcing file /usr/local/Cellar/fish/3.5.1/share/fish/config.fish
    called during startup

The content of this 99_file_post.fish file is the following

test -x ~/.local/bin/fig; and eval (~/.local/bin/fig init fish post --rcfile 99_fig_post | string split0)

Details:

macOS Fig Shell
12.6.0 Version 1.0.61 (B528) /usr/local/bin/fish
fig diagnostic

Version 1.0.61 (B528) [U.S.] 
UserShell: /usr/local/bin/fish
Bundle path: /Applications/Fig.app
Autocomplete: true
Settings.json: true
CLI installed: true
CLI tool path: /Users/benjamin/.fig/bin/fig
Accessibility: true
SSH Integration: false
Tmux Integration: false
iTerm Integration: true [Authenticated]
Hyper Integration: true
VSCode Integration: true
Docker Integration: false
Symlinked dotfiles: false
Only insert on tab: false
UNIX Socket Exists: true
Installation Script: true
PseudoTerminal Path: /Users/benjamin/bin:/Users/benjamin/Library/pnpm:/Users/benjamin/.yarn/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Applications/VMware Fusion.app/Contents/Public:/usr/local/share/dotnet:~/.dotnet/tools:/usr/local/MacGPG2/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Users/benjamin/.fig/bin:/Users/benjamin/.local/bin
SecureKeyboardInput: false
SecureKeyboardProcess: 
Current active process: ??? (???) - ???
Current terminal session: ???
Current working directory: ???
Current window identifier: ???

clo4 commented 2 years ago

Hey @bmichotte, sorry for the issue! Can you send the output of fig init fish post? If it's got sensitive info you can email to robert [at] fig [dot] io 🙂

bmichotte commented 2 years ago

Hi @SeparateRecords

here you are

# post for fish
if test -z "$FIG_DOTFILES_SOURCED"
  alias 'grm' 'git rm'
  alias 'grep' 'grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox}'
  alias 'gpv' 'git push -v'
  alias 'gpu' 'git push upstream'
  alias 'gpsup' 'git push --set-upstream origin $(git_current_branch)'
  alias 'gpristine' 'git reset --hard && git clean -dffx'
  alias 'gpr' 'git pull --rebase'
  alias 'gpoat' 'git push origin --all && git push origin --tags'
  alias 'gloga' 'git log --oneline --decorate --graph --all'
  alias 'glog' 'git log --oneline --decorate --graph'
  alias 'glod' 'git log --graph --pretty='"'"'\'"'"''"'"'%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset'"'"'\'
  alias 'git-svn-dcommit-push' 'git svn dcommit && git push github $(git_main_branch):svntrunk'
  alias 'gignore' 'git update-index --assume-unchanged'
  alias 'gignored' 'git ls-files -v | grep "^[[:lower:]]"'
  alias 'ghh' 'git help'
  alias 'bundletool' 'java -jar /Users/benjamin/bin/bundletool.jar'
  alias 'bfg' 'java -jar /Users/benjamin/bin/bfg.jar'
  alias 'clean_simulators' 'xcrun simctl delete unavailable'
  alias 'art' 'php artisan'
  alias '...' '../..'
  set -x LC_COLLATE "en_GB.UTF-8"
  alias 'gf' 'git fetch'
  alias 'gdup' 'git diff @{upstream}'
  alias 'gcn!' 'git commit -v --no-edit --amend'
  alias 'gcmsg' 'git commit -m'
  alias 'gcm' 'git checkout $(git_main_branch)'
  alias 'gclean' 'git clean -id'
  alias 'gcan!' 'git commit -v -a --no-edit --amend'
  set -x LC_NUMERIC "en_GB.UTF-8"
  alias 'gbsr' 'git bisect reset'
  set -x LS_COLORS "di=34;40:ln=35;40:so=32;40:pi=33;40:ex=31;40:bd=34;46:cd=34;43:su=0;41:sg=0;46:tw=0;42:ow=0;43:"
  alias 'gapa' 'git add --patch'
  alias 'gam' 'git am'
  alias 'download' '~/bin/download.rb'
  alias 'gbsb' 'git bisect bad'
  set -x PAGER "less"
  alias 'gb' 'git branch'
  set -x ZSH "/Users/benjamin/.oh-my-zsh"
  set -g FIG_DOTFILES_SOURCED 1
end

if test -z "$FIG_CHECKED_PROMPTS"
  begin; fig app prompts &; end
  set -g FIG_CHECKED_PROMPTS 1
end

builtin contains $HOME/.fig/bin $PATH
or set --append PATH $HOME/.fig/bin

builtin contains $HOME/.local/bin $PATH
or set --append PATH $HOME/.local/bin

# if test "$FIG_DID_NOT_EXEC_FIGTERM" = 1
#     and test "$FIG_TERM" != 1
#     or set --query INSIDE_EMACS
#     set --erase FIG_DID_NOT_EXEC_FIGTERM
#     exit
# end

# Open workflows on keyboard shortcut
set --query FIG_WORKFLOWS_KEYBIND || set FIG_WORKFLOWS_KEYBIND '\cf'

# function fig-open-workflows
#     fig run
#     commandline -f repaint
# end

# bind (string unescape $FIG_WORKFLOWS_KEYBIND) fig-open-workflows

set --export TTY (command tty)
set --export FIG_PID $fish_pid

set FIG_HOSTNAME (fig _ hostname; or command hostname -f 2> /dev/null; or command hostname)
set FIG_SHELL_PATH (fig _ get-shell)

if test -e /proc/1/cgroup; and command grep -q docker /proc/1/cgroup
    set FIG_IN_DOCKER 1
else if test -f /.dockerenv
    set FIG_IN_DOCKER 1
else
    set FIG_IN_DOCKER 0
end

function fig_osc
    builtin printf "\033]697;$argv[1]\007" $argv[2..-1]
end

function fig_copy_fn
    functions --erase $argv[2]
    functions --copy $argv[1] $argv[2]
    #builtin functions $argv[1] | sed "s/^function $argv[1]/function $argv[2]/" | source
end

function fig_fn_defined
    functions --query $argv[1]
    #test (builtin functions $argv[1] | command grep -vE '^ *(#|function |end$|$)' | command wc -l | command xargs) != 0
end

function fig_wrap_prompt
    set -l last_status $status
    fig_osc StartPrompt

    builtin printf "%b" (string join "\n" $argv)
    fig_osc EndPrompt

    return $last_status
end

function fig_preexec --on-event fish_preexec
    fig_osc PreExec

    if fig_fn_defined fig_user_mode_prompt
        fig_copy_fn fig_user_mode_prompt fish_mode_prompt
    end

    if fig_fn_defined fig_user_right_prompt
        fig_copy_fn fig_user_right_prompt fish_right_prompt
    end

    fig_copy_fn fig_user_prompt fish_prompt

    set fig_has_set_prompt 0
end

function fig_precmd --on-event fish_prompt
    set -l last_status $status

    if test -n "$SSH_TTY"
        fig_osc "SSH=1"
    else
        fig_osc "SSH=0"
    end

    fig_osc "Docker=%d" "$FIG_IN_DOCKER"
    fig_osc "Dir=%s" "$PWD"
    fig_osc "Shell=fish"
    fig_osc "ShellPath=%s" "$FIG_SHELL_PATH"
    if test -n "$WSL_DISTRO_NAME"
        fig_osc "WSLDistro=%s" "$WSL_DISTRO_NAME"
    end
    fig_osc "PID=%d" "$fish_pid"
    fig_osc "SessionId=%s" "$TERM_SESSION_ID"
    fig_osc "ExitCode=%s" "$last_status"
    fig_osc "TTY=%s" (tty)
    fig_osc "Log=%s" "$FIG_LOG_LEVEL"
    fig_osc "FishSuggestionColor=%s" "$fish_color_autosuggestion"

    if test -n "$USER"
        fig_osc "Hostname=%s@%s" "$USER" "$FIG_HOSTNAME"
    else
        fig_osc "Hostname=%s@%s" root "$FIG_HOSTNAME"
    end

    if test $fig_has_set_prompt = 1
        fig_preexec
    end

    if fig_fn_defined fish_mode_prompt
        fig_copy_fn fish_mode_prompt fig_user_mode_prompt
        function fish_mode_prompt
            fig_wrap_prompt (fig_user_mode_prompt)
        end
    end

    if fig_fn_defined fish_right_prompt
        fig_copy_fn fish_right_prompt fig_user_right_prompt
        function fish_right_prompt
            fig_wrap_prompt (fig_user_right_prompt)
        end
    end

    fig_copy_fn fish_prompt fig_user_prompt
    function fish_prompt
        fig_wrap_prompt (fig_user_prompt)
        fig_osc NewCmd
    end

    set fig_has_set_prompt 1

    if command -v fig &>/dev/null
        switch (fig _ pre-cmd)
            case EXEC_NEW_SHELL
                set -ge FIG_DOTFILES_SOURCED
                exec fish
        end
    end
end

set fig_has_set_prompt 0

if test -n "$PROCESS_LAUNCHED_BY_FIG"
    fig_osc DoneSourcing
end
clo4 commented 2 years ago

Interesting, looks like your glod alias is causing the issue. @rahulsarathy can you take a look at the quoting logic for this? I'm happy to investigate if you want but for the most part fish quoting rules are the same as zsh.

For now @bmichotte you can replace it with this string:

git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset'

The original alias has a bunch of extra unnecessary quotes in it to work around zsh's quoting rules, but fig makes it pretty simple.

Alternatively, to disable it for fish: CleanShot 2022-09-21 at 22 55 46@2x

bmichotte commented 2 years ago

Mhhh, ok, for some reason, it loots like fig imported the dotfiles from my old zsh and oh-my-zsh config and (broke it btw)

CleanShot 2022-09-21 at 15 19 00

Is there a way to specify the dotfiles, we want to import ?