Efficiently open files from the CLI (using xdg-open and fasd)
# Add this line to your .bashrc / .zshrc | |
# The 'o' script (cf below) must be in your $PATH | |
# 'fasd' (cf https://github.com/clvv/fasd) must be in your $PATH too | |
alias oo='fasd -a -e o' | |
# Now use 'oo criteria<TAB>' (iterate through matches) or simply 'oo' (list entries) | |
# Given that 'fasd' is a requirement, maybe have a look at the 'zz' alias |
#!/bin/bash | |
# Take a single argument (file / directory) | |
# Display the corresponding mimetype and default app | |
# Used to configure the XDG database | |
if [ -z "$1" ]; then | |
echo "Argument is needed!" | |
exit | |
else | |
MIMETYPE=`xdg-mime query filetype $1` | |
HANDLER=`xdg-mime query default $MIMETYPE` | |
echo "Type '$MIMETYPE' is handled by '$HANDLER'" | |
echo "Map it to 'gvim' with the following command:" | |
echo "xdg-mime default gvim.desktop $MIMETYPE" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment