From 87a038f7dfb4a119be505550567ab2dd78f0790a Mon Sep 17 00:00:00 2001 From: Eyre_S Date: Mon, 22 Apr 2024 18:55:30 +0800 Subject: [PATCH] more zsh configs --- zsh/custom.zsh | 55 +++++++++++++++++++++++++++++++--- zsh/env.example.zsh | 72 +++++++++++++++++++++++++++++++++++++++++++++ zsh/p10k.zsh | 14 ++++----- 3 files changed, 130 insertions(+), 11 deletions(-) diff --git a/zsh/custom.zsh b/zsh/custom.zsh index 1b2820e..270f2e0 100644 --- a/zsh/custom.zsh +++ b/zsh/custom.zsh @@ -10,9 +10,49 @@ profile-edit () { profile } -#--- bat (cat) ---# +#--- custom CLI tools ---# + +# Fast run a command in background with no log +bg () { + eval "$@" &>/dev/null &disown +} + +# Execute an AppImage and automaticly +x it +appimage() { + chmod a+x $1 + $1 +} + +# Set file meta (like icons) in linux fs +file-set-icon () { + gio set $1 metadata::custom-icon $2 +} +file-rm-icon () { + gio set -d $1 metadata::custom-icon +} +cat-desktop-ini () { + cat "$1/desktop.ini" +} + +# # where proxy +# proxy () { +# export http_proxy="http://127.0.0.1:7890" +# export https_proxy="http://127.0.0.1:7890" +# echo "HTTP Proxy on" +# } + +# # where noproxy +# noproxy () { +# unset http_proxy +# unset https_proxy +# echo "HTTP Proxy off" +# } + +#--- enhanced CLI tools aliases ---# + +# cat is bat alias cat='bat' -#--- lsd ---# +# ls is lsd alias cols='lsd' alias crls='cols' alias ccls='crls -g' @@ -25,8 +65,15 @@ alias l='cl' alias ll='cll' alias la='cla' alias lgg='ccls --tree' - -#--- zoxide (cd) ---# +# cd is zoxide # zoxide must init after compinit is called eval "$(zoxide init zsh)" alias cd='z' +# fuck +eval $(thefuck --alias) + +#--- other toolchain alias ---# + +# gcc c++ complier +alias gpp="g++" +alias gxx="g++" \ No newline at end of file diff --git a/zsh/env.example.zsh b/zsh/env.example.zsh index 41b6d69..1252824 100644 --- a/zsh/env.example.zsh +++ b/zsh/env.example.zsh @@ -10,6 +10,9 @@ #- Compilation flags # export ARCHFLAGS="-arch x86_64" +#- Fix ^M when enter Enter +# stty icrnl + #--- Editor (for normal system local/remote) ---# if [[ -n $SSH_CONNECTION ]]; then export EDITOR='code' @@ -37,3 +40,72 @@ export config="$HOME/.config" # Workspaces export ws="$HOME/documents/workspaces" export tests="$data/__test" + +#--- messing configs ---# + +# jetbrains netfilter vmoption +___MY_VMOPTIONS_SHELL_FILE="${HOME}/.jetbrains.vmoptions.sh"; if [ -f "${___MY_VMOPTIONS_SHELL_FILE}" ]; then . "${___MY_VMOPTIONS_SHELL_FILE}"; fi + +# yay别名,用于自定义仿apt命令 +yat() { + + if [ -z "$1" ];then + yay; + else + if [ "$1" = "install" ];then # 安装软件 + yay -S $2; + elif [ "$1" = "update" ];then # 更新数据库 + yay -Sy; + elif [ "$1" = "upgrade" ];then # 升级整个系统,y是更新数据库,u是升级软件 + yay -Syu; + elif [ "$1" = "search" ];then # 在包数据库中查询软件 + yay -Ss $2; + elif [ "$1" = "show" ];then # 显示软件的详细信息 + yay -Si $2; + elif [ "$1" = "info" ];then # 显示已安装的软件的详细信息 * + yay -Qi $2; + elif [ "$1" = "path" ];then # 列出已安装的软件使用的文件夹 * + yay -Ql $2; + elif [ "$1" = "clear" ];then # 清除软件缓存,即/var/cache/pacman/pkg目录下的文件 + yay -Sc; + elif [ "$1" = "clean" ];then # alias ^ + yay -Sc; + elif [ "$1" = "remove" ];then # 删除单个软件 + yay -R $2; + elif [ "$1" = "autoremove" ];then # 删除指定软件及其没有被其他已安装软件使用的依赖关系 + if [ -z "$2" ] + then + yay -c; + else + yay -Rs $2; + fi + elif [ "$1" = "list" ];then # 查询已安装的软件包 + yay -Qs $2; + elif [ "$1" = "dpkg" ];then # 从本地文件安装 + yay -U $2; + else # 默认命令参数 + yay $1; + fi + fi + +} + + +# minecraft +minecraft () { + pwd_curr = pwd + cd /data/Game/Minecraft/ + java -jar /data/Game/Minecraft/HMCL.jar + cd $pwd_curr +} + +#--- Welcome Message! ---# +# May only works in some system + +if [ -z "$RC_LOADED" ];then + lolcat "/etc/motd.backup" +else + lolcat "$HOME/.config/motd/100-rc" +fi + +RC_LOADED=1 diff --git a/zsh/p10k.zsh b/zsh/p10k.zsh index d8c245b..7d7635f 100644 --- a/zsh/p10k.zsh +++ b/zsh/p10k.zsh @@ -35,6 +35,7 @@ os_icon # os identifier # cpu_arch # CPU architecture context # user@hostname + disk_usage # disk usage ip # ip address and bandwidth usage for a specified network interface # public_ip # public IP address # =========================[ Line #2 ]========================= @@ -52,18 +53,16 @@ # last prompt line gets hidden if it would overlap with left prompt. typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=( # =========================[ Line #1 ]========================= - proxy # system-wide http/https/ftp proxy - battery # internal battery - ram # free RAM # wifi # wifi speed # vpn_ip # virtual private network indicator - # load # CPU load - # disk_usage # disk usage - # swap # used swap + proxy # system-wide http/https/ftp proxy todo # todo items (https://github.com/todotxt/todo.txt-cli) timewarrior # timewarrior tracking status (https://timewarrior.net/) taskwarrior # taskwarrior task count (https://taskwarrior.org/) per_directory_history # Oh My Zsh per-directory-history local/global indicator + ram # free RAM + # swap # used swap + # load # CPU load time # current time newline # \n # =========================[ Line #2 ]========================= @@ -116,6 +115,7 @@ midnight_commander # midnight commander shell (https://midnight-commander.org/) nix_shell # nix shell (https://nixos.org/nixos/nix-pills/developing-with-nix-shell.html) chezmoi_shell # chezmoi shell (https://www.chezmoi.io/) + battery # internal battery # =========================[ Line #3 ]========================= newline # example # example user-defined segment (see prompt_example function below) @@ -1710,7 +1710,7 @@ # - verbose: Enable instant prompt and print a warning when detecting console output during # zsh initialization. Choose this if you've never tried instant prompt, haven't # seen the warning, or if you are unsure what this all means. - typeset -g POWERLEVEL9K_INSTANT_PROMPT=quiet + typeset -g POWERLEVEL9K_INSTANT_PROMPT=off # Hot reload allows you to change POWERLEVEL9K options after Powerlevel10k has been initialized. # For example, you can type POWERLEVEL9K_BACKGROUND=red and see your prompt turn red. Hot reload