Skip to content

Loading…

Use xdg-open in Linux for the o alias, if it's available. #1478

Closed
wants to merge 2 commits into from

3 participants

@gokceneraslan

No description provided.

@mcornella
Collaborator

Hi! Please be aware that you're defining the alias outside the check for fasd installed, and that by making the alternative condition only on Darwin you're essentially leaving all the other systems that are not Linux nor Darwin without a defined alias.
For (1), put the if inside the check again; for (2), convert your elif into an else.

@gokceneraslan

(1) I don't get (1). if-elif-fi block that I added is already within if-fi block of 'fasd' check, isn't it?
(2) Is there an "open" command that opens files in "all the other systems that are not Linux nor Darwin"? open is an OS X command, right? So why do you want me to define an alias to "open" for those systems?

@mcornella
Collaborator

(1) I don't get (1). if-elif-fi block that I added is already within if-fi block of 'fasd' check, isn't it?

It is indeed inside the fasd check, I probably had a brainfart looking at the diff :smile:

Regarding the alternative alias, I think OpenBSD also has an open command that does that, and then there is Windows / Cygwin. Other plugins do these kind of check as well, such as jira, node and web-search. Also #1039

I don't know the right approach anyway, what do you say?

@mcornella
Collaborator

Hi @gokceneraslan, it's been a long time but I managed to find a clean and simple solution, look at the web-search plugin to safely open across different platforms.
What do you say if I put that into a lib file so we can use it across the project?

@gokceneraslan

Looks very similar to my patch :) Go go go...

@mcornella
Collaborator

Hi @gokceneraslan, I finally implemented my standard open command. Now the o alias is a -e open_command, where open_command is the implemented function.

Please test if it works correctly since I don't have fasd to check.
Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 2 deletions.
  1. +6 −2 plugins/fasd/fasd.plugin.zsh
View
8 plugins/fasd/fasd.plugin.zsh
@@ -1,6 +1,10 @@
if [ $commands[fasd] ]; then # check if fasd is installed
eval "$(fasd --init auto)"
alias v='f -e vim'
- alias o='a -e open'
-fi
+ if [[ $('uname') == 'Linux' ]] && [ $commands[xdg-open] ]; then
+ alias o='a -e xdg-open'
+ elif [[ $('uname') == 'Darwin' ]]; then
+ alias o='a -e open'
+ fi
+fi
Something went wrong with that request. Please try again.