From f055bfbedc9e0cd9b933a23a1474123782a9e4da Mon Sep 17 00:00:00 2001 From: emma Date: Sun, 19 Nov 2023 14:48:04 -0700 Subject: [PATCH] fixed zsh config nonsense --- install.sh | 4 +- noire-carnation/functions | 75 ++++++++++++++++++++++++ noire-carnation/profile | 118 -------------------------------------- noire-carnation/zprofile | 1 + noire-carnation/zshrc | 23 +++++++- 5 files changed, 101 insertions(+), 120 deletions(-) create mode 100755 noire-carnation/functions create mode 100644 noire-carnation/zprofile diff --git a/install.sh b/install.sh index d152654..327b15a 100755 --- a/install.sh +++ b/install.sh @@ -24,5 +24,7 @@ do ln -sf "$PWD/$item" "$XDG_CONFIG_HOME/$inst_path" done -ln -sf "$PWD/$MACHINE/zshrc" "$HOME/.zshrc" +ln -sf "$PWD/$MACHINE/functions" "$HOME/.functions" ln -sf "$PWD/$MACHINE/profile" "$HOME/.profile" +ln -sf "$PWD/$MACHINE/zprofile" "$HOME/.zprofile" +ln -sf "$PWD/$MACHINE/zshrc" "$HOME/.zshrc" diff --git a/noire-carnation/functions b/noire-carnation/functions new file mode 100755 index 0000000..495ebc2 --- /dev/null +++ b/noire-carnation/functions @@ -0,0 +1,75 @@ +#!/bin/sh + +bmv() { + if test -z "$1"; then + printf "Usage: %s [files pattern]...\n" "$0" 1>&2 + return 64 # sysexits.h(3) EX_USAGE + fi + + while test -n "$2"; do + for file in $1; do + mv "$file" "$(printf "%s" "$file" | sed "s/\$2//g")" + done + + shift 2 + done +} + +ix() { + curl -F 'f:1=<-' ix.io +} + +myip() { + curl icanhazip.com +} + +paclean() { + for package in `pacman -Qtq`; do + pacman -Qi "$package" + + printf "Uninstall? [y/N] " + read resp + + # TODO: Add undo + if [ "$resp" != "y" ] && [ "$resp" != "Y" ]; then + printf "Skipped %s.\n\n" "$package" 1>&2 + else + printf "Queued %s for uninstall.\n\n" "$package" 1>&2 + packages="$packages$package " + fi + done + su -c "pacman -Rns $packages" +} + + +sc() { + if test -z "$1"; then + printf "Usage: %s URI...\n" "$0" 1>&2 + return 64 # sysexits.h(3) EX_USAGE + fi + + while "$1"; do + scdl --original-name --debug -l "$1" >> log 2>&1 + done +} + +up() { # updates everything on the system + command -v apk >/dev/null && su -c 'apk update' + command -v cargo-install-update >/dev/null && cargo install-update --all --git + command -v kiss >/dev/null && su -c 'kiss u' && su -c 'kiss U' + command -v nvim >/dev/null && nvim +PlugUpdate -c x -c x + if command -v paru >/dev/null; then paru + elif command -v pacman >/dev/null; then su -c 'pacman -Syyu'; fi + + CWD="$PWD" + + command -v git >/dev/null && \ + for dir in $HOME/.local/src/git/*/*/*/ + do + printf '%s\n' "$dir" + cd "$dir" + git pull --all + done + + cd "$CWD" +} diff --git a/noire-carnation/profile b/noire-carnation/profile index 279265d..0858d5c 100644 --- a/noire-carnation/profile +++ b/noire-carnation/profile @@ -43,74 +43,6 @@ GTK_IM_MODULE=ibus; export GTK_IM_MODULE QT_IM_MODULE=ibus; export QT_IM_MODULE XMODIFIERS=@im=ibus; export XMODIFIERS -# functions -bmv() { - if test -z "$1"; then - printf "Usage: %s [files pattern]...\n" "$0" 1>&2 - return 64 # sysexits.h(3) EX_USAGE - fi - - while test -n "$2"; do - for file in $1; do - mv "$file" "$(printf "%s" "$file" | sed "s/\$2//g")" - done - - shift 2 - done -} - -ix() { - curl -F 'f:1=<-' ix.io -} - -myip() { - curl icanhazip.com -} - -paclean() { - for package in `pacman -Qtq`; do - pacman -Qi "$package" - - printf "Uninstall? [y/N] " - read resp - - # TODO: Add undo - if [ "$resp" != "y" ] && [ "$resp" != "Y" ]; then - printf "Skipped %s.\n\n" "$package" 1>&2 - else - printf "Queued %s for uninstall.\n\n" "$package" 1>&2 - packages="$packages$package " - fi - done - su -c "pacman -Rns $packages" -} - - -sc() { - if test -z "$1"; then - printf "Usage: %s URI...\n" "$0" 1>&2 - return 64 # sysexits.h(3) EX_USAGE - fi - - while "$1"; do - scdl --original-name --debug -l "$1" >> log 2>&1 - done -} - -yt() { - if test -z "$1"; then - printf "Usage: %s URI...\n" "$0" 1>&2 - return 64 # sysexits.h(3) EX_USAGE - fi - - while "$1"; do - yt-dlp -vx --split-chapters -o \ - "chapter:%(fulltitle)s - %(section_number)s %(section_title)s.%(ext)s" \ - "$1" --audio-quality 0 >> log 2>&1 - shift - done -} - # aliases alias weather="curl 'wttr.in/?0'" alias vi="busybox vi" @@ -121,54 +53,4 @@ case "$SHELL" in set -o vi PS1='$ ' ;; - - */zsh ) - HISTFILE="$XDG_DATA_HOME/zsh/histfile" - HISTSIZE=999999999 - SAVEHIST="$HISTSIZE" - - unsetopt autocd - bindkey -v - zstyle :compinstall filename "$HOME/.zshrc" - autoload -Uz compinit - compinit -u -d "$XDG_CACHE_HOME/zsh/zcompdump" - setopt rmstarsilent - - # Key (zshmisc(1)): - # - # '%F{$color}$x%f': Change foreground color of $x to $color - # '%B$x%b': Make $x bold - # '%n': $USER - # '%M': $HOST - # '%1~': $PWD, but shows '~' if at $HOME - # '%(?.#.%?)': - # '%n(x.true.false)' evaluates ternary expression for condition x, where n - # is an integer, by default '0': - # '?': If the last command’s exit status was 0, true - # '#': Prints literal '#' to the prompt - # '[%?]': Prints the last exit status with literal brackets surrounding it - - ERR='[%f%F{green}%?%f%F{blue}]%f' - ERR_LINE="%(?.#.$ERR)" - - LINE1='%F{blue}╭%f %B%F{blue}%n%f@%F{magenta}%M%f%b' - LINE2='%F{blue}│%f %F{green}%B%0~%b%f' - LINE3="%F{blue}╰─$ERR_LINE%f " - - PS1="$(printf "%s\n%s\n%s" "$LINE1" "$LINE2" "$LINE3")"; export PS1 - - plugindir="/usr/share/zsh/plugins" - for plugin in \ - "$plugindir/zsh-autosuggestions/zsh-autosuggestions.zsh" \ - "$plugindir/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh" \ - "$plugindir/zsh-history-substring-search/zsh-history-substring-search.zsh" - do - source "$plugin" - done - - bindkey -a 'k' history-substring-search-up - bindkey -a 'j' history-substring-search-down - - alias which="$HOME/.local/bin/which" - ;; esac diff --git a/noire-carnation/zprofile b/noire-carnation/zprofile new file mode 100644 index 0000000..4661182 --- /dev/null +++ b/noire-carnation/zprofile @@ -0,0 +1 @@ +test -e "$HOME/.profile" && source "$HOME/.profile" diff --git a/noire-carnation/zshrc b/noire-carnation/zshrc index af4a10e..67fff4c 100644 --- a/noire-carnation/zshrc +++ b/noire-carnation/zshrc @@ -1 +1,22 @@ -source "$HOME/.profile" +test -e "$HOME/.functions" && source "$HOME/.functions" + +unsetopt autocd +bindkey -v +zstyle :compinstall filename "$HOME/.zshrc" +autoload -Uz compinit +compinit -u -d "$XDG_CACHE_HOME/zsh/zcompdump" +setopt rmstarsilent + +plugindir="/usr/share/zsh/plugins" +for plugin in \ + "$plugindir/zsh-autosuggestions/zsh-autosuggestions.zsh" \ + "$plugindir/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh" \ + "$plugindir/zsh-history-substring-search/zsh-history-substring-search.zsh" +do + source "$plugin" +done + +bindkey -a 'k' history-substring-search-up +bindkey -a 'j' history-substring-search-down + +alias which="$HOME/.local/bin/which"