From 6861ccd62fb8b15b842b9181bc46e2d07fe24b0f Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Sat, 27 May 2023 11:20:10 +0200 Subject: added chpwd hook --- config/essentials/zsh/.zshrc | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'config/essentials/zsh/.zshrc') diff --git a/config/essentials/zsh/.zshrc b/config/essentials/zsh/.zshrc index b2cda54..d5d5465 100644 --- a/config/essentials/zsh/.zshrc +++ b/config/essentials/zsh/.zshrc @@ -87,6 +87,16 @@ set_wt () { print -Pn "\e]0;%n@%m on %~\a" } add-zsh-hook -Uz precmd set_wt +function osc7 { + local LC_ALL=C + export LC_ALL + + setopt localoptions extendedglob + input=( ${(s::)PWD} ) + uri=${(j::)input/(#b)([^A-Za-z0-9_.\!~*\'\(\)-\/])/%${(l:2::0:)$(([##16]#match))}} + print -n "\e]7;file://${HOSTNAME}${uri}\e\\" +} +add-zsh-hook -Uz chpwd osc7 # prompt -- cgit v1.2.3 From c9d472cceabb1b9612219ad77ced69e48ce9a0d7 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Mon, 29 May 2023 01:45:19 +0200 Subject: fixed commands executing two times --- config/essentials/zsh/.zshrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config/essentials/zsh/.zshrc') diff --git a/config/essentials/zsh/.zshrc b/config/essentials/zsh/.zshrc index d5d5465..8ba4ece 100644 --- a/config/essentials/zsh/.zshrc +++ b/config/essentials/zsh/.zshrc @@ -80,7 +80,7 @@ rehash_precmd() { # window title hooks add-zsh-hook -Uz precmd rehash_precmd set_wt_action () { - print -Pn "\e]0;$1\a" + print -Pn '\e]0;$1\a' } add-zsh-hook -Uz preexec set_wt_action set_wt () { -- cgit v1.2.3 From 5a82c13c615965161eb6ce930f6392ec4849a5e3 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Sun, 11 Jun 2023 21:14:07 +0200 Subject: added opening textfile by name --- config/essentials/zsh/.zshrc | 25 ++++++++++++++++++++++++- config/essentials/zsh/aliases.zsh | 4 ---- 2 files changed, 24 insertions(+), 5 deletions(-) (limited to 'config/essentials/zsh/.zshrc') diff --git a/config/essentials/zsh/.zshrc b/config/essentials/zsh/.zshrc index 8ba4ece..b603a04 100644 --- a/config/essentials/zsh/.zshrc +++ b/config/essentials/zsh/.zshrc @@ -15,6 +15,20 @@ then exit fi +isTextFile() +{ + if [ -n "$1" ] + then + local file_type=$(file -b --mime-type "$1") + if [[ $file_type == text/* ]] + then + return + else + return 1 + fi + fi +} + autoload -U select-word-style autoload -z edit-command-line zle -N edit-command-line @@ -97,7 +111,16 @@ function osc7 { print -n "\e]7;file://${HOSTNAME}${uri}\e\\" } 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() { + isTextFile "$1" && + "$EDITOR" "$1" +} +add-zsh-hook -Uz preexec open_file # prompt PS1=' %B%(#.%F{1}.%F{13})[%n%b%f@%B%F{6}%m]%b%f %3~ ' diff --git a/config/essentials/zsh/aliases.zsh b/config/essentials/zsh/aliases.zsh index c9ea751..cd4c021 100644 --- a/config/essentials/zsh/aliases.zsh +++ b/config/essentials/zsh/aliases.zsh @@ -217,10 +217,6 @@ alias fzps='ps aux | tail +2 | fzf --bind \ alias asf='alias | fzf' alias fzh="tac $HISTFILE | fzf | tee /dev/stderr | clipp" -alias -s conf="$EDITOR" -alias -s txt="$EDITOR" -alias -s c="$EDITOR" -alias -s z80="$EDITOR" alias -s zip='unzip -l' alias -s tar='tar tf' -- cgit v1.2.3 From 34ad05634aba96818fca33610288dbe85fb081c0 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Mon, 12 Jun 2023 02:12:25 +0200 Subject: fix not being able to execute files --- config/essentials/zsh/.zshrc | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'config/essentials/zsh/.zshrc') 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 -- cgit v1.2.3 From 02e6f3719d2a19a5aa35439819a37ad92c2751aa Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Tue, 13 Jun 2023 10:34:46 +0200 Subject: removed double declaration of function --- config/essentials/zsh/.zshrc | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'config/essentials/zsh/.zshrc') diff --git a/config/essentials/zsh/.zshrc b/config/essentials/zsh/.zshrc index 8f37225..4a28ce2 100644 --- a/config/essentials/zsh/.zshrc +++ b/config/essentials/zsh/.zshrc @@ -15,20 +15,6 @@ then exit fi -isTextFile() -{ - if [ -n "$1" ] - then - local file_type=$(file -b --mime-type "$1") - if [[ $file_type == text/* ]] - then - return - else - return 1 - fi - fi -} - autoload -U select-word-style autoload -z edit-command-line zle -N edit-command-line -- cgit v1.2.3