diff options
Diffstat (limited to 'config/essentials/zsh/.zshrc')
-rw-r--r-- | config/essentials/zsh/.zshrc | 36 |
1 files changed, 13 insertions, 23 deletions
diff --git a/config/essentials/zsh/.zshrc b/config/essentials/zsh/.zshrc index 83da0f6..d8675d4 100644 --- a/config/essentials/zsh/.zshrc +++ b/config/essentials/zsh/.zshrc @@ -3,12 +3,9 @@ if [[ "/dev/tty1" = "$TTY" || "/dev/tty2" = "$TTY" ]] && [[ "$(id -u)" -ne 0 ]] then clear - eval "$(keychain --dir "$XDG_CONFIG_HOME/keychain" --eval --quiet --agents gpg 3A626DD20A32EB2E5DD9CE71CFD9ABC97158CD5D 2> /dev/null)" - eval "$(keychain --dir "$XDG_CONFIG_HOME/keychain" --noask --eval --quiet --agents ssh 2> /dev/null)" - clear if [ "/dev/tty1" = "$TTY" ] then - Hyprland > /dev/null 2>&1 + startw > /dev/null 2>&1 else startx > /dev/null 2>&1 fi @@ -28,7 +25,7 @@ zle -N add-surround surround zle -N change-surround surround compinit -if grep -qi "debian\|ubuntu" /etc/os-release 2>/dev/null +if grep -qi "debian\|ubuntu" /usr/lib/os-release /etc/os-release 2>/dev/null then sfiles=( /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh @@ -41,7 +38,7 @@ else fi sfiles+=( ~/.config/zsh/functions.zsh - ~/.config/zsh/aliases.zsh + ~/.config/zsh/aliases.sh ) for f in "${sfiles[@]}"; do test -f "$f" && source "$f" @@ -67,17 +64,14 @@ bindkey "^['" quote-line isTextFile() { - if [ ! -f "$1" ] - then + [ -f "$1" ] && + # will execute the file, I'd rather not have an error message + [ ${1::2} != "./" ] && + [ ${1::1} != "/" ] && + ! type "$1" > /dev/null && + # is text file? + file -b --mime-type "$1" | grep -q "^text/" || return 1 - fi - - file_type=$(file -b --mime-type "$1") - if [[ "$file_type" == text/* ]] - then - return - fi - return 1 } # rehash hook @@ -113,17 +107,13 @@ function osc7 { } add-zsh-hook -Uz chpwd osc7 command_not_found_handler () { - isTextFile "$1" || - echo "zsh: command not found: $1" >&2 -} -# open file with file name -open_file() { - if [ ${1:0:2} != "./" ] && isTextFile "$1" + if [[ -o interactive ]] && isTextFile "$1" then "$EDITOR" "$1" + else + echo "zsh: command not found: $1" >&2 fi } -add-zsh-hook -Uz preexec open_file # prompt PS1=' %B%(#.%F{1}.%F{13})[%n%b%f@%B%F{6}%m]%b%f %3~ ' |