summaryrefslogtreecommitdiff
path: root/config/essentials/zsh
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2023-06-12 02:12:25 +0200
committerRaymaekers Luca <raymaekers.luca@gmail.com>2023-06-12 02:12:25 +0200
commit34ad05634aba96818fca33610288dbe85fb081c0 (patch)
tree49661fa0ea1af4b550cf224de94dd0ae55a9ab0a /config/essentials/zsh
parent5a82c13c615965161eb6ce930f6392ec4849a5e3 (diff)
fix not being able to execute files
Diffstat (limited to 'config/essentials/zsh')
-rw-r--r--config/essentials/zsh/.zshrc19
1 files changed, 18 insertions, 1 deletions
diff --git a/config/essentials/zsh/.zshrc b/config/essentials/zsh/.zshrc
index b603a04..8f37225 100644
--- a/config/essentials/zsh/.zshrc
+++ b/config/essentials/zsh/.zshrc
@@ -79,6 +79,21 @@ bindkey "^Xe" edit-command-line
bindkey "^[." insert-last-word
bindkey "^['" quote-line
+isTextFile()
+{
+ if [ ! -f "$1" ]
+ then
+ return 1
+ fi
+
+ file_type=$(file -b --mime-type "$1")
+ if [[ "$file_type" == text/* ]]
+ then
+ return
+ fi
+ return 1
+}
+
# rehash hook
zshcache_time="$(date +%s%N)"
autoload -Uz add-zsh-hook
@@ -117,8 +132,10 @@ command_not_found_handler () {
}
# open file with file name
open_file() {
- isTextFile "$1" &&
+ if [ ${1:0:2} != "./" ] && isTextFile "$1"
+ then
"$EDITOR" "$1"
+ fi
}
add-zsh-hook -Uz preexec open_file