sebastiancarlos

joined 1 year ago
 
 
6
submitted 1 month ago* (last edited 1 month ago) by [email protected] to c/[email protected]
 

Either self-hosted or cloud, I assume many of you keep a server around for personal things. And I'm curious about the cool stuff you've got running on your personal servers.

What services do you host? Any unique stuff? Do you interact with it through ssh, termux, web server?

[–] [email protected] 4 points 3 months ago (1 children)

And what's your workflow when working with lots of files in projects with fish?

 

Hey,

As an avid CLI user, I always aimed to master non-interactive tools to perform most of my work, given that they are easy to use, create, extend, and connect.

However, I found myself dealing with software projects with many files (mostly under the yoke of corporate oppression; an ordeal which I endure to sustain myself, as most of those reading me do, and therefore I will not go further into this topic) and started to hit the limits of non-interactive tools to find and edit files. Indeed, I could go faster if I followed the temptation of monstrous IDEs, as I did in my innocent past.

I did not despair, as naturally I heard of the usefulness of interactive fuzzy finders such as fzf. After spending an afternoon evaluating the tool, I concluded that it indeed increases the complexity of my workflow. Still, this complexity is managed in a sensible way that follows the UNIX tradition.

I now ask you two general questions:

  • Did you reach similar conclusions to me and decide to use interactive fuzzy finders to solve working on software projects with many files?
  • If you use fzf or similar tools, what can you tell me about your workflow? Any other third-party tools? Do you integrate it into your scripts? Any advice that you can give me out of a long time of experience using the tool that is not easily conveyed by the documentation?

I also ask this very specific question:

  • The one part of fzf which I found missing was a way to interact with the results of grep, and to automatically place the selected file(s) in the prompt or an editor. For that, I created the following two commands. Do you have a similar workflow when you want to bring the speed of fuzzy finding to grep?
#! /usr/bin/env bash

# gf: grep + fzf
# basically a wrapper for 'grep <ARGS> | fzf | cut -f 1 -d:'

# print usage on -h/--help
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
    echo "Usage: gf <grep-args>"
    echo
    echo "~~~ that feel when no 'gf' ~~~"
    echo
    echo "- Basically a wrapper for 'grep <ARGS> | fzf | cut -f 1 -d:'"
    echo "- Opens fzf with grep results, and prints the selected filename(s)"
    echo "- Note: As this is meant to search files, it already adds the -r flag"
    echo
    echo "Example:"
    echo "  $ nvim \`gf foobar\`"
    echo "  $ gf foobar | xargs nvim"
    exit 0
fi

# run grep with arguments, pipe to fzf, and print the filename(s) selected
custom_grep () {
    grep -E --color=always --binary-files=without-match --recursive "$@"
}
remove_color () {
    sed -E 's/\x1b\[[0-9;]*[mK]//g'
}
custom_fzf () {
    fzf --ansi --height ~98%
}
grep_output=$(custom_grep "$@")
if [[ "$?" -ne 0 ]]; then
    exit 1
else
    echo "$grep_output" | custom_fzf | remove_color | cut -f 1 -d:
fi
#! /usr/bin/env bash

# ge: grep + fzf + editor
# basically a wrapper for 'grep <ARGS> | fzf | cut -f 1 -d: | $EDITOR'

# print usage on -h/--help
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
    echo "Usage: ge <grep-args>"
    echo
    echo "- Basically a wrapper for 'grep <ARGS> | fzf | cut -f 1 -d: | \$EDITOR'"
    echo "- Opens fzf with grep results, and edits the selected file(s)"
    echo "- Note: As this is meant to search files, it already adds the -r flag"
    echo "- Note: Internally, it uses the 'gf' command"
    echo
    echo "Example:"
    echo "  $ ge foobar"
    exit 0
fi

# takes output from 'gf' and opens it in $EDITOR
grep_fzf_output=$(gf "$@")
if [[ -n "$grep_fzf_output" ]]; then
  $EDITOR "$grep_fzf_output"
fi

Have a wonderful day, you CLI cowboys.

[–] [email protected] 1 points 3 months ago

Unlike a password manager that just logs you in, Beachpatrol can run any automation task, like checking your email, downloading files, or filling out forms. You have to create Playwright scripts for these tasks and run them from a shell command. There is an example script already in the commands folder, which you can run with the command beackmsg smoke-test. The sky is the limit, basically.

[–] [email protected] 2 points 3 months ago* (last edited 3 months ago) (1 children)

Cool project! I'll check it out.

Regarding userscripting, from the F.A.Q.:

Why use an external automation tool (Playwright) instead of a browser extension?

While Beachpatrol allows to control the browser from both the OS and from a browser extension, our priority was the OS. Therefore, something like Playwright was the natural choice.

Furthermore, while controlling the browser from an extensions is possible, Manifest v3 removed the ability to execute third-party strings of code. Popular automation extensions like Greasemonkey and Tampermonkey could also be affected by Manifest v3. The alternative is to embed the code into the extension, but that would requires re-bundling the extensions after every change. Other tricks do exist to make this approach work, and there is some hope for future Manifest v3 solutions, but this path is certainly tricky.

It is more likely that Selenium and related tools will continue to work in the foreseeable future given the business demand for traditional browser testing.

[–] [email protected] -1 points 10 months ago

Point taken, but Big Tech systematically does equally bad things while disguising them behind DevRel, so I think it's justified to poke fun at that.

[–] [email protected] 12 points 10 months ago (6 children)

Just curious, what would be a correct translation?

[–] [email protected] 65 points 10 months ago (6 children)

The joke is that it's hard to tell if this is a joke because the lines between good intentions, corporate jargon, and feasibility have been blurred beyond recognition both here and in the real world.

It's also funny that after all these years, i18n is still a mess. Moreover, even if translations are standard in GUIs and documentation, for some reason, everyone is okay with defaulting to English for the oldest form of computer interaction.

Also, the joke is whatever you want it to be. Follow your dreams.

[–] [email protected] 1 points 10 months ago

Cool, thanks! Look like there are things like xrandr for Wayland with this functionality. the burn-in is not so bad right now but I'll keep this in mind.

[–] [email protected] 2 points 10 months ago

Yes! I use it all the time. No idea why it's not more popular

[–] [email protected] 4 points 10 months ago (2 children)

.bashrc:

# Prompt
# "Make it simple, just the dollar sign"
# "Say no more, fam"
# - if error code is not 0, then prepend [N] where N is the error code
# - if user is root, use red and #
blue='\e[34m'
red='\e[31m'
bold='\e[1m'
reset='\e[0m'
PS1='$( status=$?; [ $status -ne 0 ] &amp;&amp; echo "[$status] ")\['"$blue""$bold"'\]$\['"$reset"'\] '

if [[ $EUID -eq 0 ]]; then
  PS1='$( status=$?; [ $status -ne 0 ] &amp;&amp; echo "[$status] ")\['"$red""$bold"'\]#\['"$reset"'\] '
fi

.inputrc:

# vi mode, change to 'emacs' here if you prefer
set editing-mode vi

# vi INSERT prompt
set vi-ins-mode-string "\1\e[30;44m\2 INS \1\e[0m\2 "

# vi NORMAL prompt
set vi-cmd-mode-string "\1\e[30;47m\2 NOR \1\e[0m\2 "
[–] [email protected] 1 points 10 months ago* (last edited 10 months ago)

answered in post. btw it seems this is a Sway only issue, so it makes sense it's ok in i3

[–] [email protected] 1 points 10 months ago

answered in post

[–] [email protected] 1 points 10 months ago (3 children)

answered in post

view more: next ›