From 1a855899b08e6d3060cec6e2b5a50db67c40c140 Mon Sep 17 00:00:00 2001 From: Derek Taylor Date: Sat, 5 Dec 2020 15:30:52 -0600 Subject: [PATCH] Adding starship prompt. --- .bashrc | 16 ++- .config/fish/config.fish | 111 ++------------- .zshrc | 295 ++++++++++++++++++++++----------------- 3 files changed, 187 insertions(+), 235 deletions(-) diff --git a/.bashrc b/.bashrc index 933cbd6..e87aec8 100644 --- a/.bashrc +++ b/.bashrc @@ -5,7 +5,6 @@ # |____/ |_| # # My bash config. Not much to see here; just some pretty standard stuff. -# PATH="$HOME/.local/bin${PATH:+:${PATH}}" # adding .local/bin to $PATH ### EXPORT export TERM="xterm-256color" # getting proper colors @@ -14,10 +13,8 @@ export ALTERNATE_EDITOR="" # setting for emacsclient export EDITOR="emacsclient -t -a ''" # $EDITOR use Emacs in terminal export VISUAL="emacsclient -c -a emacs" # $VISUAL use Emacs in GUI mode -# sets vim as manpager -export MANPAGER="/bin/sh -c \"col -b | vim --not-a-term -c 'set ft=man ts=8 nomod nolist noma' -\"" - -### SET VI MODE IN BASH SHELL +### SET VI MODE ### +# Comment this line out to enable default emacs-like bindings set -o vi bind -m vi-command 'Control-l: clear-screen' bind -m vi-insert 'Control-l: clear-screen' @@ -26,7 +23,8 @@ bind -m vi-insert 'Control-l: clear-screen' [[ $- != *i* ]] && return ### PROMPT -PS1='[\u@\h \W]\$ ' +# This is commented out if using starship prompt +# PS1='[\u@\h \W]\$ ' ### PATH if [ -d "$HOME/.bin" ] ; @@ -203,11 +201,17 @@ alias tb="nc termbin.com 9999" alias rr='curl -s -L https://raw.githubusercontent.com/keroserene/rickrollrc/master/roll.sh | bash' ### RANDOM COLOR SCRIPT ### +# Get this script from my GitLab: gitlab.com/dwt1/shell-color-scripts +# Or install it from the Arch User Repository: shell-color-scripts colorscript random +### SOURCING BROOT ### source /home/dt/.config/broot/launcher/bash/br ### BASH INSULTER ### if [ -f /etc/bash.command-not-found ]; then . /etc/bash.command-not-found fi + +### SETTING THE STARSHIP PROMPT ### +eval "$(starship init bash)" diff --git a/.config/fish/config.fish b/.config/fish/config.fish index 29c395e..c5997cf 100644 --- a/.config/fish/config.fish +++ b/.config/fish/config.fish @@ -4,116 +4,28 @@ # | |_| || | http://www.gitlab.com/dwt1/ # |____/ |_| # -# My fish config. Not much to see here. Some pretty standard stuff. +# My fish config. Not much to see here; just some pretty standard stuff. + +### EXPORT ### set -U fish_user_paths $fish_user_paths $HOME/.local/bin/ set fish_greeting # Supresses fish's intro message set TERM "xterm-256color" # Sets the terminal type set EDITOR "emacsclient -t -a ''" # $EDITOR use Emacs in terminal set VISUAL "emacsclient -c -a emacs" # $VISUAL use Emacs in GUI mode - -### PROMPT ### -# This was the 'sashimi' prompt from oh-my-fish. -function fish_prompt - set -l last_status $status - set -l cyan (set_color -o 98be65) - set -l yellow (set_color -o yellow) - set -g red (set_color -o 98be65) - set -g blue (set_color -o blue) - set -l green (set_color -o green) - set -g normal (set_color magenta) - - set -l ahead (_git_ahead) - set -g whitespace ' ' - - if test $last_status = 0 - set initial_indicator "$green◆" - set status_indicator "$normal❯$cyan❯$green❯" - else - set initial_indicator "$red✖ $last_status" - set status_indicator "$red❯$red❯$red❯" - end - set -l cwd $cyan(basename (prompt_pwd)) - - if [ (_git_branch_name) ] - if test (_git_branch_name) = 'master' - set -l git_branch (_git_branch_name) - set git_info "$normal git:($red$git_branch$normal)" - else - set -l git_branch (_git_branch_name) - set git_info "$normal git:($blue$git_branch$normal)" - end - if [ (_is_git_dirty) ] - set -l dirty "$yellow ✗" - set git_info "$git_info$dirty" - end - end - # Notify if a command took more than 5 minutes - if [ "$CMD_DURATION" -gt 300000 ] - echo The last command took (math "$CMD_DURATION/1000") seconds. - end - - echo -n -s $initial_indicator $whitespace $cwd $git_info $whitespace $ahead $status_indicator $whitespace -end - -function _git_ahead - set -l commits (command git rev-list --left-right '@{upstream}...HEAD' ^/dev/null) - if [ $status != 0 ] - return - end - set -l behind (count (for arg in $commits; echo $arg; end | grep '^<')) - set -l ahead (count (for arg in $commits; echo $arg; end | grep -v '^<')) - switch "$ahead $behind" - case '' # no upstream - case '0 0' # equal to upstream - return - case '* 0' # ahead of upstream - echo "$blue↑$normal_c$ahead$whitespace" - case '0 *' # behind upstream - echo "$red↓$normal_c$behind$whitespace" - case '*' # diverged from upstream - echo "$blue↑$normal$ahead $red↓$normal_c$behind$whitespace" - end -end - -function _git_branch_name - echo (command git symbolic-ref HEAD ^/dev/null | sed -e 's|^refs/heads/||') -end - -function _is_git_dirty - echo (command git status -s --ignore-submodules=dirty ^/dev/null) -end - -function fish_mode_prompt - switch $fish_bind_mode - case default - set_color --bold red - echo '(N) ' - case insert - set_color --bold green - echo '(I) ' - case replace_one - set_color --bold green - echo '(R) ' - case visual - set_color --bold brmagenta - echo '(V) ' - case '*' - set_color --bold red - echo '(?) ' - end - set_color normal -end -### END OF PROMPT ### - - -### DEFAULT EMACS MODE OR VI MODE ### +### SET EITHER DEFAULT EMACS MODE OR VI MODE ### function fish_user_key_bindings # fish_default_key_bindings fish_vi_key_bindings end ### END OF VI MODE ### +### AUTOCOMPLETE AND HIGHLIGHT COLORS ### +set fish_color_normal brcyan +set fish_color_autosuggestion '#7d7d7d' +set fish_color_command brcyan +set fish_color_error '#ff6c6b' +set fish_color_param brcyan ### SPARK ### set -g spark_version 1.0.0 @@ -378,3 +290,6 @@ alias kakd="/usr/bin/kak -d -s mysession &" # Get this script from my GitLab: gitlab.com/dwt1/shell-color-scripts # Or install it from the Arch User Repository: shell-color-scripts colorscript random + +### SETTING THE STARSHIP PROMPT ### +starship init fish | source diff --git a/.zshrc b/.zshrc index fdf7321..5c15139 100644 --- a/.zshrc +++ b/.zshrc @@ -3,130 +3,89 @@ # | | | || | http://www.youtube.com/c/DistroTube # | |_| || | http://www.gitlab.com/dwt1/ # |____/ |_| +# My zsh config. Not much to see here; just some pretty standard stuff. -PATH="$HOME/.local/bin${PATH:+:${PATH}}" -EDITOR="nvim" -export TERM="xterm-256color" +### EXPORT +export TERM="xterm-256color" # getting proper colors +export HISTORY_IGNORE="(ls|cd|pwd|exit|sudo reboot|history|cd -|cd ..)" +export EDITOR="emacsclient -t -a ''" # $EDITOR use Emacs in terminal +export VISUAL="emacsclient -c -a emacs" # $VISUAL use Emacs in GUI mode -# If you come from bash you might have to change your $PATH. -# export PATH=$HOME/bin:/usr/local/bin:$PATH +### SET VI MODE ### +# Comment this line out to enable default emacs-like bindings +bindkey -v + +# If not running interactively, don't do anything +[[ $- != *i* ]] && return + +### PATH +if [ -d "$HOME/.bin" ] ; + then PATH="$HOME/.bin:$PATH" +fi + +if [ -d "$HOME/.local/bin" ] ; + then PATH="$HOME/.local/bin:$PATH" +fi + +### CHANGE TITLE OF TERMINALS +case ${TERM} in + xterm*|rxvt*|Eterm*|aterm|kterm|gnome*|alacritty|st|konsole*) + PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/\~}\007"' + ;; + screen*) + PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/\~}\033\\"' + ;; +esac + +### ARCHIVE EXTRACTION +# usage: ex +ex () +{ + if [ -f $1 ] ; then + case $1 in + *.tar.bz2) tar xjf $1 ;; + *.tar.gz) tar xzf $1 ;; + *.bz2) bunzip2 $1 ;; + *.rar) unrar x $1 ;; + *.gz) gunzip $1 ;; + *.tar) tar xf $1 ;; + *.tbz2) tar xjf $1 ;; + *.tgz) tar xzf $1 ;; + *.zip) unzip $1 ;; + *.Z) uncompress $1;; + *.7z) 7z x $1 ;; + *.deb) ar x $1 ;; + *.tar.xz) tar xf $1 ;; + *.tar.zst) unzstd $1 ;; + *) echo "'$1' cannot be extracted via ex()" ;; + esac + else + echo "'$1' is not a valid file" + fi +} + +### OH MY ZSH ### # Path to your oh-my-zsh installation. -ZSH=/usr/share/oh-my-zsh/ - -# Set name of the theme to load --- if set to "random", it will -# load a random theme each time oh-my-zsh is loaded, in which case, -# to know which specific one was loaded, run: echo $RANDOM_THEME -# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes -# ZSH_THEME="powerlevel9k" -POWERLEVEL9K_CONTEXT_DEFAULT_BACKGROUND='5' -POWERLEVEL9K_CONTEXT_DEFAULT_FOREGROUND='0' -POWERLEVEL9K_STATUS_OK_BACKGROUND='8' -POWERLEVEL9K_VCS_CLEAN_BACKGROUND='11' -POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND='8' -POWERLEVEL9K_VCS_MODIFIED_BACKGROUND='10' -POWERLEVEL9K_VCS_MAX_SYNC_LATENCY_SECONDS='0.05' -POWERLEVEL9K_VI_INSERT_MODE_STRING='INSERT' -POWERLEVEL9K_VI_COMMAND_MODE_STRING='NORMAL' -POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status history time) -POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=() -ZLE_RPROMPT_INDENT=0 - -# Set list of themes to pick from when loading at random -# Setting this variable when ZSH_THEME=random will cause zsh to load -# a theme from this variable instead of looking in ~/.oh-my-zsh/themes/ -# If set to an empty array, this variable will have no effect. -# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" ) - -# Uncomment the following line to use case-sensitive completion. -# CASE_SENSITIVE="true" - -# Uncomment the following line to use hyphen-insensitive completion. -# Case-sensitive completion must be off. _ and - will be interchangeable. -HYPHEN_INSENSITIVE="true" - -# Uncomment the following line to disable bi-weekly auto-update checks. -DISABLE_AUTO_UPDATE="true" - -# Uncomment the following line to change how often to auto-update (in days). -# export UPDATE_ZSH_DAYS=13 - -# Uncomment the following line to disable colors in ls. -# DISABLE_LS_COLORS="true" - -# Uncomment the following line to disable auto-setting terminal title. -# DISABLE_AUTO_TITLE="true" - -# Uncomment the following line to enable command auto-correction. -# ENABLE_CORRECTION="true" - -# Uncomment the following line to display red dots whilst waiting for completion. -# COMPLETION_WAITING_DOTS="true" - -# Uncomment the following line if you want to disable marking untracked files -# under VCS as dirty. This makes repository status check for large repositories -# much, much faster. -# DISABLE_UNTRACKED_FILES_DIRTY="true" - -# Uncomment the following line if you want to change the command execution time -# stamp shown in the history command output. -# You can set one of the optional three formats: -# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" -# or set a custom format using the strftime function format specifications, -# see 'man strftime' for details. -# HIST_STAMPS="mm/dd/yyyy" +ZSH=$HOME/.oh-my-zsh # Would you like to use another custom folder than $ZSH/custom? # ZSH_CUSTOM=/path/to/new-custom-folder # Which plugins would you like to load? -# Standard plugins can be found in ~/.oh-my-zsh/plugins/* -# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/ -# Example format: plugins=(rails git textmate ruby lighthouse) # Add wisely, as too many plugins slow down shell startup. -plugins=( - git -) - - -# User configuration - -# export MANPATH="/usr/local/man:$MANPATH" - -# You may need to manually set your language environment -# export LANG=en_US.UTF-8 - -# Preferred editor for local and remote sessions -if [[ -n $SSH_CONNECTION ]]; then - export EDITOR='vim' -else - export EDITOR='mvim' -fi - -# Compilation flags -# export ARCHFLAGS="-arch x86_64" - -# ssh -# export SSH_KEY_PATH="~/.ssh/rsa_id" - -# Set personal aliases, overriding those provided by oh-my-zsh libs, -# plugins, and themes. Aliases can be placed here, though oh-my-zsh -# users are encouraged to define aliases within the ZSH_CUSTOM folder. -# For a full list of active aliases, run `alias`. -# -# Example aliases -# alias zshconfig="mate ~/.zshrc" -# alias ohmyzsh="mate ~/.oh-my-zsh" - -ZSH_CACHE_DIR=$HOME/.cache/oh-my-zsh -if [[ ! -d $ZSH_CACHE_DIR ]]; then - mkdir $ZSH_CACHE_DIR -fi +# Defning the plugins needs to happen before sourcing oh-my-zsh. +plugins=(command-not-found + emacs + git + history + zsh-interactive-cd) +# Sourcing oh-my-zsh +# Your plugins will not work without this source. source $ZSH/oh-my-zsh.sh -source ~/powerlevel10k/powerlevel10k.zsh-theme -### ALIASES ### +### ALIASES ### # root privileges alias doas="doas --" @@ -134,29 +93,104 @@ alias doas="doas --" # navigation alias ..='cd ..' alias ...='cd ../..' +alias .3='cd ../../..' +alias .4='cd ../../../..' +alias .5='cd ../../../../..' -# vim -alias vim=nvim +# vim and emacs +alias vim="nvim" +alias em="/usr/bin/emacs -nw" +alias emacs="emacsclient -c -a 'emacs'" +alias doomsync="~/.emacs.d/bin/doom sync" +alias doomdoctor="~/.emacs.d/bin/doom doctor" +alias doomupgrade="~/.emacs.d/bin/doom upgrade" +alias doompurge="~/.emacs.d/bin/doom purge" -# broot -alias br='br -dhp' -alias bs='br --sizes' +# pacman and yay +alias pacsyu='sudo pacman -Syyu' # update only standard pkgs +alias yaysua="yay -Sua --noconfirm" # update only AUR pkgs +alias yaysyu="yay -Syu --noconfirm" # update standard pkgs and AUR pkgs +alias unlock="sudo rm /var/lib/pacman/db.lck" # remove pacman lock +alias cleanup='sudo pacman -Rns $(pacman -Qtdq)' # remove orphaned packages + +# get fastest mirrors +alias mirror="sudo reflector -f 30 -l 30 --number 10 --verbose --save /etc/pacman.d/mirrorlist" +alias mirrord="sudo reflector --latest 50 --number 20 --sort delay --save /etc/pacman.d/mirrorlist" +alias mirrors="sudo reflector --latest 50 --number 20 --sort score --save /etc/pacman.d/mirrorlist" +alias mirrora="sudo reflector --latest 50 --number 20 --sort age --save /etc/pacman.d/mirrorlist" # Changing "ls" to "exa" alias ls='exa -al --color=always --group-directories-first' # my preferred listing alias la='exa -a --color=always --group-directories-first' # all files and dirs alias ll='exa -l --color=always --group-directories-first' # long format alias lt='exa -aT --color=always --group-directories-first' # tree listing +alias l.='exa -a | egrep "^\."' + +# Colorize grep output (good for log files) +alias grep='grep --color=auto' +alias egrep='egrep --color=auto' +alias fgrep='fgrep --color=auto' + +# confirm before overwriting something +alias cp="cp -i" +alias mv='mv -i' +alias rm='rm -i' # adding flags -alias cp="cp -i" # confirm before overwriting something alias df='df -h' # human-readable sizes alias free='free -m' # show sizes in MB alias lynx='lynx -cfg=~/.lynx/lynx.cfg -lss=~/.lynx/lynx.lss -vikeys' alias vifm='./.config/vifm/scripts/vifmrun' -# the terminal rickroll -alias rr='curl -s -L https://raw.githubusercontent.com/keroserene/rickrollrc/master/roll.sh | bash' +## get top process eating memory +alias psmem='ps auxf | sort -nr -k 4' +alias psmem10='ps auxf | sort -nr -k 4 | head -10' + +## get top process eating cpu ## +alias pscpu='ps auxf | sort -nr -k 3' +alias pscpu10='ps auxf | sort -nr -k 3 | head -10' + +# git +alias addup='git add -u' +alias addall='git add .' +alias branch='git branch' +alias checkout='git checkout' +alias clone='git clone' +alias commit='git commit -m' +alias fetch='git fetch' +alias pull='git pull origin' +alias push='git push origin' +alias status='git status' +alias tag='git tag' +alias newtag='git tag -a' + +# Merge Xresources +alias merge='xrdb -merge ~/.Xresources' + +# get error messages from journalctl +alias jctl="journalctl -p 3 -xb" + +# gpg encryption +# verify signature for isos +alias gpg-check="gpg2 --keyserver-options auto-key-retrieve --verify" +# receive the key of a developer +alias gpg-retrieve="gpg2 --keyserver-options auto-key-retrieve --receive-keys" + +# youtube-dl +alias yta-aac="youtube-dl --extract-audio --audio-format aac " +alias yta-best="youtube-dl --extract-audio --audio-format best " +alias yta-flac="youtube-dl --extract-audio --audio-format flac " +alias yta-m4a="youtube-dl --extract-audio --audio-format m4a " +alias yta-mp3="youtube-dl --extract-audio --audio-format mp3 " +alias yta-opus="youtube-dl --extract-audio --audio-format opus " +alias yta-vorbis="youtube-dl --extract-audio --audio-format vorbis " +alias yta-wav="youtube-dl --extract-audio --audio-format wav " +alias ytv-best="youtube-dl -f bestvideo+bestaudio " + +# switch between shells +alias tobash="sudo chsh $USER -s /bin/bash && echo 'Now log out.'" +alias tozsh="sudo chsh $USER -s /bin/zsh && echo 'Now log out.'" +alias tofish="sudo chsh $USER -s /bin/fish && echo 'Now log out.'" # bare git repo alias for dotfiles alias config="/usr/bin/git --git-dir=$HOME/dotfiles --work-tree=$HOME" @@ -164,16 +198,15 @@ alias config="/usr/bin/git --git-dir=$HOME/dotfiles --work-tree=$HOME" # termbin alias tb="nc termbin.com 9999" -### SET VI MODE IN BASH SHELL -set -o vi +# the terminal rickroll +alias rr='curl -s -L https://raw.githubusercontent.com/keroserene/rickrollrc/master/roll.sh | bash' -### SET VIM AS MANPAGER ### -export MANPAGER="/bin/sh -c \"col -b | vim --not-a-term -c 'set ft=man ts=8 nomod nolist noma' -\"" +### RANDOM COLOR SCRIPT ### +# Get this script from my GitLab: gitlab.com/dwt1/shell-color-scripts +# Or install it from the Arch User Repository: shell-color-scripts +colorscript random -### BASH POWERLINE ### -source ~/.bash-powerline.sh - -### BROOT ### +### SOURCING BROOT ### source /home/dt/.config/broot/launcher/bash/br ### BASH INSULTER ### @@ -181,8 +214,8 @@ if [ -f /etc/bash.command-not-found ]; then . /etc/bash.command-not-found fi -### RANDOM COLOR SCRIPT ### -colorscript random +### SETTING THE STARSHIP PROMPT ### +eval "$(starship init zsh)" + + -### SETS VI MODE ### -bindkey -v