Skip to content

Latest commit

 

History

History
42 lines (30 loc) · 733 Bytes

File metadata and controls

42 lines (30 loc) · 733 Bytes

Compile the program:

go build -o sonar

Create a shell function in your .bashrc or .zshrc: You need to set the file path to your binary

sonar() {
    local selection_file="/tmp/sonar_selection"
    
    # Run interactively TUI 
    <file_path>/sonar "$@"
    exit_code=$?
    
    # Check if selection was made
    if [[ -f "$selection_file" && "$exit_code" -eq 0 ]]; then
        target_dir="$(cat "$selection_file")"
        rm -f "$selection_file"
        
        if [[ -n "$target_dir" ]]; then
            cd "$target_dir" || echo "Failed to cd into $target_dir"
        fi
    fi

}

Source your shell configuration:

source ~/.bashrc  # or ~/.zshrc

Now you can run:

sonar