From f9a2c6b30771f355e6e56414e296fa205c702bd5 Mon Sep 17 00:00:00 2001 From: Sohrab Behdani Date: Sun, 17 Nov 2024 00:41:24 +0330 Subject: [PATCH] Added Existing ZSH config --- usr/share/parchlinux/zsh/alias/alias | 19 + .../parchlinux/zsh/functions/extract.zsh | 78 +++ .../parchlinux/zsh/theme/parch.zsh-theme | 498 ++++++++++++++++++ usr/share/parchlinux/zsh/zshrc-example | 64 +++ 4 files changed, 659 insertions(+) create mode 100644 usr/share/parchlinux/zsh/alias/alias create mode 100644 usr/share/parchlinux/zsh/functions/extract.zsh create mode 100644 usr/share/parchlinux/zsh/theme/parch.zsh-theme create mode 100644 usr/share/parchlinux/zsh/zshrc-example diff --git a/usr/share/parchlinux/zsh/alias/alias b/usr/share/parchlinux/zsh/alias/alias new file mode 100644 index 0000000..fd1462f --- /dev/null +++ b/usr/share/parchlinux/zsh/alias/alias @@ -0,0 +1,19 @@ +alias ll="ls -al" +alias ln="ln -v" +alias ls='ls --color=auto' +alias grep='grep --color=auto' +alias mkdir="mkdir -p" +alias e="$EDITOR" +alias v="$VISUAL" + + +# Pretty print the path +alias path='echo $PATH | tr -s ":" "\n"' + +# Easier navigation: ..., ...., ....., and - +alias ...="cd ../.." +alias ....="cd ../../.." +alias .....="cd ../../../.." +alias -- -="cd -" + +alias "uu"="paru -Syyu" diff --git a/usr/share/parchlinux/zsh/functions/extract.zsh b/usr/share/parchlinux/zsh/functions/extract.zsh new file mode 100644 index 0000000..5cc30d1 --- /dev/null +++ b/usr/share/parchlinux/zsh/functions/extract.zsh @@ -0,0 +1,78 @@ +alias x=extract + +extract() { + local remove_archive + local success + local extract_dir + + if (( $# == 0 )); then + cat <<-'EOF' >&2 + Usage: extract [-option] [file ...] + + Options: + -r, --remove Remove archive after unpacking. + EOF + fi + + remove_archive=1 + if [[ "$1" == "-r" ]] || [[ "$1" == "--remove" ]]; then + remove_archive=0 + shift + fi + + while (( $# > 0 )); do + if [[ ! -f "$1" ]]; then + echo "extract: '$1' is not a valid file" >&2 + shift + continue + fi + + success=0 + extract_dir="${1:t:r}" + case "${1:l}" in + (*.tar.gz|*.tgz) (( $+commands[pigz] )) && { pigz -dc "$1" | tar xv } || tar zxvf "$1" ;; + (*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$1" ;; + (*.tar.xz|*.txz) + tar --xz --help &> /dev/null \ + && tar --xz -xvf "$1" \ + || xzcat "$1" | tar xvf - ;; + (*.tar.zma|*.tlz) + tar --lzma --help &> /dev/null \ + && tar --lzma -xvf "$1" \ + || lzcat "$1" | tar xvf - ;; + (*.tar.zst|*.tzst) + tar --zstd --help &> /dev/null \ + && tar --zstd -xvf "$1" \ + || zstdcat "$1" | tar xvf - ;; + (*.tar) tar xvf "$1" ;; + (*.tar.lz) (( $+commands[lzip] )) && tar xvf "$1" ;; + (*.gz) (( $+commands[pigz] )) && pigz -dk "$1" || gunzip -k "$1" ;; + (*.bz2) bunzip2 "$1" ;; + (*.xz) unxz "$1" ;; + (*.lzma) unlzma "$1" ;; + (*.z) uncompress "$1" ;; + (*.zip|*.war|*.jar|*.sublime-package|*.ipsw|*.xpi|*.apk|*.aar|*.whl) unzip "$1" -d $extract_dir ;; + (*.rar) unrar x -ad "$1" ;; + (*.rpm) mkdir "$extract_dir" && cd "$extract_dir" && rpm2cpio "../$1" | cpio --quiet -id && cd .. ;; + (*.7z) 7za x "$1" ;; + (*.deb) + mkdir -p "$extract_dir/control" + mkdir -p "$extract_dir/data" + cd "$extract_dir"; ar vx "../${1}" > /dev/null + cd control; tar xzvf ../control.tar.gz + cd ../data; extract ../data.tar.* + cd ..; rm *.tar.* debian-binary + cd .. + ;; + (*.zst) unzstd "$1" ;; + (*) + echo "extract: '$1' cannot be extracted" >&2 + success=1 + ;; + esac + + (( success = $success > 0 ? $success : $? )) + (( $success == 0 )) && (( $remove_archive == 0 )) && rm "$1" + shift + done +} diff --git a/usr/share/parchlinux/zsh/theme/parch.zsh-theme b/usr/share/parchlinux/zsh/theme/parch.zsh-theme new file mode 100644 index 0000000..a79d596 --- /dev/null +++ b/usr/share/parchlinux/zsh/theme/parch.zsh-theme @@ -0,0 +1,498 @@ +#!/bin/zsh + +#ParchLinux zsh prompt + + + +# Formatting aliases +# (add more if you need) +reset=$'\e[0m' +bold=$'\e[1m' +faint=$'\e[2m' +italic=$'\e[3m' +underline=$'\e[4m' +invert=$'\e[7m' +# ... + +# Foreground color aliases +black=$'\e[30m' +red=$'\e[31m' +green=$'\e[32m' +yellow=$'\e[33m' +blue=$'\e[34m' +magenta=$'\e[35m' +cyan=$'\e[36m' +white=$'\e[37m' +light_black=$'\e[90m' +light_red=$'\e[91m' +light_green=$'\e[92m' +light_yellow=$'\e[93m' +light_blue=$'\e[94m' +light_magenta=$'\e[95m' +light_cyan=$'\e[96m' +light_white=$'\e[97m' + +# Background color aliases +black_back=$'\e[40m' +red_back=$'\e[41m' +green_back=$'\e[42m' +yellow_back=$'\e[43m' +blue_back=$'\e[44m' +magenta_back=$'\e[45m' +cyan_back=$'\e[46m' +white_back=$'\e[47m' +light_black_back=$'\e[100m' +light_red_back=$'\e[101m' +light_green_back=$'\e[102m' +light_yellow_back=$'\e[103m' +light_blue_back=$'\e[104m' +light_magenta_back=$'\e[105m' +light_cyan_back=$'\e[106m' +light_white_back=$'\e[107m' + +# Custom colors +# REF: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters +# orange_yellow=$'\e[38;5;214m' # example 8-bit color +# orange_brown=$'\e[38;2;191;116;46m' # example rgb color +# ... + +# Flags +! [ -z "$SSH_TTY$SSH_CONNECTION$SSH_CLIENT" ] +IS_SSH=$? # 0=true, 1=false + + + +# ------------------------------------------------------------------------------ +# Customization +# Use the following variables to customize the theme +# These variables can also be set in your ~/.zshrc after sourcing this file +# The style aliases for ANSI SGR codes (defined above) can be used there too + +# Info sources (enclose in single quotes as these will be eval'd, use empty string to hide segment) +HEADLINE_USER_CMD='echo $USER' +HEADLINE_HOST_CMD='hostname -s' # consider 'basename "$VIRTUAL_ENV"' to replace host with environment +HEADLINE_PATH_CMD='print -rP "%~"' +HEADLINE_GIT_BRANCH_CMD='headline_git_branch' +HEADLINE_GIT_STATUS_CMD='headline_git_status' + +# Info symbols (optional) +HEADLINE_USER_PREFIX='' +HEADLINE_HOST_PREFIX='' # consider " " +HEADLINE_PATH_PREFIX='' +HEADLINE_BRANCH_PREFIX='' + +# Info joints +HEADLINE_USER_BEGIN='' +if [ $IS_SSH = 0 ]; then HEADLINE_USER_BEGIN='=> '; fi +HEADLINE_USER_TO_HOST=' @ ' +HEADLINE_HOST_TO_PATH=': ' +HEADLINE_PATH_TO_BRANCH=' | ' # only used when no padding between and +HEADLINE_PATH_TO_PAD='' # used if padding between and +HEADLINE_PAD_TO_BRANCH='' # used if padding between and +HEADLINE_BRANCH_TO_STATUS=' [' +HEADLINE_STATUS_TO_STATUS='' # between each status section, consider "]" +HEADLINE_STATUS_END=']' + +# Info padding character +HEADLINE_PAD_CHAR=' ' # repeated for space between and + +# Info truncation symbol +HEADLINE_TRUNC_PREFIX='...' # shown where or is truncated, consider "…" + +# Info styles +HEADLINE_STYLE_DEFAULT='' # style applied to entire info line +HEADLINE_STYLE_JOINT=$light_black +HEADLINE_STYLE_USER=$bold$red +HEADLINE_STYLE_HOST=$bold$yellow +HEADLINE_STYLE_PATH=$bold$blue +HEADLINE_STYLE_BRANCH=$bold$cyan +HEADLINE_STYLE_STATUS=$bold$magenta + +# Info options +HEADLINE_INFO_MODE=precmd # precmd|prompt (whether info line is in PROMPT or printed by precmd) + # use "precmd" for window resize to work properly (but Ctrl+L doesn't show info line) + # use "prompt" for Ctrl+L to clear properly (but window resize eats previous output) + +# Separator options +HEADLINE_LINE_MODE=on # on|auto|off (whether to print the line above the prompt) + +# Separator character +HEADLINE_LINE_CHAR='_' # repeated for line above information + +# Separator styles +HEADLINE_STYLE_JOINT_LINE=$HEADLINE_STYLE_JOINT +HEADLINE_STYLE_USER_LINE=$HEADLINE_STYLE_USER +HEADLINE_STYLE_HOST_LINE=$HEADLINE_STYLE_HOST +HEADLINE_STYLE_PATH_LINE=$HEADLINE_STYLE_PATH +HEADLINE_STYLE_BRANCH_LINE=$HEADLINE_STYLE_BRANCH +HEADLINE_STYLE_STATUS_LINE=$HEADLINE_STYLE_STATUS + +# Git branch characters +HEADLINE_GIT_HASH=':' # hash prefix to distinguish from branch + +# Git status characters +# To set individual status styles use "%{$reset