summaryrefslogtreecommitdiff
path: root/.zshrc
diff options
context:
space:
mode:
authorSyndamia <kamen.d.mladenov@protonmail.com>2022-01-12 17:42:21 +0200
committerSyndamia <kamen.d.mladenov@protonmail.com>2022-01-12 17:42:21 +0200
commitf6e46f0decdd8f04f40f1171f253f4c6ca2e4411 (patch)
tree7bfa5a56181bebf4de4de6b9b46ff55cb389da2e /.zshrc
parent9d611a9dc98ff4394781b6a93f937751edeb3bc1 (diff)
downloaddotfiles-f6e46f0decdd8f04f40f1171f253f4c6ca2e4411.tar
dotfiles-f6e46f0decdd8f04f40f1171f253f4c6ca2e4411.tar.gz
dotfiles-f6e46f0decdd8f04f40f1171f253f4c6ca2e4411.zip
Made aliases smarter and reworked some functions
Diffstat (limited to '.zshrc')
-rw-r--r--.zshrc136
1 files changed, 69 insertions, 67 deletions
diff --git a/.zshrc b/.zshrc
index c84a246..4e26d66 100644
--- a/.zshrc
+++ b/.zshrc
@@ -66,8 +66,8 @@ device="desktop" # can be either "desktop" (default when empty), "server" or "an
# }}}
# Alien {{{
- source ~/alien/alien.zsh
-
+ source ~/.zsh/alien/alien.zsh
+
# Visuals {{{
export ALIEN_THEME="gruvbox"
export ALIEN_SECTION_BATTERY_FG=223
@@ -76,7 +76,7 @@ device="desktop" # can be either "desktop" (default when empty), "server" or "an
export ALIEN_SECTION_USER_BG=66
export ALIEN_GIT_TRACKED_COLOR=196
export ALIEN_GIT_UN_TRACKED_COLOR=214
-
+
if [[ $device == "server" ]]; then
export ALIEN_SECTION_BATTERY_FG=0
export ALIEN_SECTION_BATTERY_BG=67
@@ -92,10 +92,10 @@ device="desktop" # can be either "desktop" (default when empty), "server" or "an
export ALIEN_GIT_MOD_SYM=﯂
export ALIEN_GIT_NEW_SYM=?
# }}}
-
+
# Sections configuration {{{
export ALIEN_SECTION_TIME_FORMAT=%H:%M:%S
-
+
export ALIEN_SECTIONS_LEFT=(
left_cap
ssh
@@ -107,7 +107,7 @@ device="desktop" # can be either "desktop" (default when empty), "server" or "an
newline
prompt
)
-
+
export ALIEN_SECTIONS_RIGHT=(
exit
time
@@ -115,7 +115,7 @@ device="desktop" # can be either "desktop" (default when empty), "server" or "an
right_end_cap
)
# }}}
-
+
# Custom sections {{{
alien_prompt_section_left_cap() {
__section=(
@@ -123,14 +123,14 @@ device="desktop" # can be either "desktop" (default when empty), "server" or "an
foreground $ALIEN_SECTION_USER_BG
)
}
-
+
alien_prompt_section_right_end_cap() {
__section=(
content "%B%b"
foreground $ALIEN_SECTION_BATTERY_BG
)
}
-
+
alien_prompt_section_git_branch() {
local __branch_info=
if [[ $(alien_is_git) == 1 ]]; then
@@ -144,7 +144,7 @@ device="desktop" # can be either "desktop" (default when empty), "server" or "an
background $ALIEN_SECTION_EXIT_BG
)
}
-
+
alien_prompt_section_git_status() {
local __stash_info=
local __lr_info=
@@ -164,7 +164,7 @@ device="desktop" # can be either "desktop" (default when empty), "server" or "an
)
}
# }}}
-
+
# Section overrides {{{
alien_prompt_section_exit() {
__section=(
@@ -174,14 +174,14 @@ device="desktop" # can be either "desktop" (default when empty), "server" or "an
separator 1
)
}
-
+
alien_prompt_section_prompt() {
__section=(
content "%B${ALIEN_PROMPT_SYM}%b "
foreground "%(?.$ALIEN_PROMPT_FG.$ALIEN_SECTION_EXIT_BG_ERROR)"
)
}
-
+
alien_battery_stat(){
__os=$(uname)
if [[ ${__os} = "Linux" ]]; then
@@ -200,7 +200,7 @@ device="desktop" # can be either "desktop" (default when empty), "server" or "an
fi
unset __os __bat_power __bat_power_ind __bat_per
}
-
+
alien_prompt_section_battery() {
local __to_return=" "
if [ -n "$(upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep state)" ]; then
@@ -220,7 +220,7 @@ device="desktop" # can be either "desktop" (default when empty), "server" or "an
echo " syndamia.com"
fi
}
-
+
alien_prompt_section_ssh() {
local __ssh_info
__ssh_info=$(alien_ssh_client)
@@ -269,33 +269,45 @@ device="desktop" # can be either "desktop" (default when empty), "server" or "an
# Aliases {{{
# portage {{{
- alias seq="sudo emerge --quiet-build -v"
- alias sep="sudo emerge -pv"
- alias sen="sudo ego sync && sudo emerge --quiet-build -vuDN @world"
+ if [[ -x "$(command -v emerge)" ]]; then
+ alias seq="sudo emerge --quiet-build -v"
+ alias sep="sudo emerge -pv"
+ alias sen="sudo ego sync && sudo emerge --quiet-build -vuDN @world"
+ alias ses="sudo emerge -s"
+ alias seS="sudo emerge -S"
+ alias sec="sudo emerge -cv"
+ alias seC="sudo emerge -Cv"
+ alias secp="sudo emerge -cpv"
+ alias seCp="sudo emerge -Cpv"
+ fi
# }}}
# dnf {{{
- # alias sdi="sudo dnf install -y"
- # alias sdr="sudo dnf remove -y"
- # alias sda="sudo dnf autoremove -y"
- # # If you're using dotnet from the "packages-microsoft-com-prod" repo, make sure to
- # # add "exclude=dotnet* aspnetcore* netstandard*" inside the /etc/yum.repos.d/fedora.repo, /etc/yum.repos.d/fedora-updates.repo and potentially /etc/yum.repos.d/fedora33.repo
- # alias sdu="sudo dnf upgrade -y && sudo dnf autoremove -y && sudo youtube-dl --update && wget -O - https://raw.githubusercontent.com/laurent22/joplin/master/Joplin_install_and_update.sh | bash && needs-restarting -r"
- #
- # alias ds="dnf search"
- # alias dcs="dnf copr search"
- # alias dp="dnf provides"
- # alias di="dnf info"
- #
- # alias sdce="sudo dnf copr enable -y"
- # alias sdcei='f() { sudo dnf copr enable -y $1 && sudo dnf install -y $2; unset -f f }; f'
+ if [[ -x "$(command -v dnf)" ]]; then
+ alias sdi="sudo dnf install -y"
+ alias sdr="sudo dnf remove -y"
+ alias sda="sudo dnf autoremove -y"
+ # If you're using dotnet from the "packages-microsoft-com-prod" repo, make sure to
+ # add "exclude=dotnet* aspnetcore* netstandard*" inside the /etc/yum.repos.d/fedora.repo, /etc/yum.repos.d/fedora-updates.repo and potentially /etc/yum.repos.d/fedora33.repo
+ alias sdu="sudo dnf upgrade -y && sudo dnf autoremove -y && sudo youtube-dl --update && wget -O - https://raw.githubusercontent.com/laurent22/joplin/master/Joplin_install_and_update.sh | bash && needs-restarting -r"
+
+ alias ds="dnf search"
+ alias dcs="dnf copr search"
+ alias dp="dnf provides"
+ alias di="dnf info"
+
+ alias sdce="sudo dnf copr enable -y"
+ alias sdcei='f() { sudo dnf copr enable -y $1 && sudo dnf install -y $2; unset -f f }; f'
+ fi
# }}}
# apt {{{
- # alias sasy="sudo apt install -y"
- # alias sary="sudo apt remove -y"
- # alias saty="sudo apt autoremove -y"
- # alias sagt="sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y && sudo youtube-dl --update && wget -O - https://raw.githubusercontent.com/laurent22/joplin/master/Joplin_install_and_update.sh | bash"
+ if [[ -x "$(command -v apt-get)" ]]; then
+ alias sasy="sudo apt install -y"
+ alias sary="sudo apt remove -y"
+ alias saty="sudo apt autoremove -y"
+ alias sagt="sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y && sudo youtube-dl --update && wget -O - https://raw.githubusercontent.com/laurent22/joplin/master/Joplin_install_and_update.sh | bash"
+ fi
# }}}
if [[ device != "server" ]]; then
@@ -314,6 +326,10 @@ device="desktop" # can be either "desktop" (default when empty), "server" or "an
alias q="exit"
alias x="exit"
+
+ alias cdg="cdcomb ~/Programming/GitHub-repos/"
+ alias cdl="cdcomb ~/Programming/GitLab-repos/"
+ alias cds="cdcomb ~/Programming/source/"
# }}}
# Application specific {{{
@@ -331,10 +347,6 @@ device="desktop" # can be either "desktop" (default when empty), "server" or "an
alias grls="grit tree"
alias sdudiscord="wget -O discord.tar.gz \"https://discord.com/api/download?platform=linux&format=tar.gz\" && tar -xzf discord.tar.gz && sudo rm -rf /opt/Discord && sudo mv Discord /opt"
-
- alias cdg="cd ~/Programming/GitHub-repos/ && mcd"
- alias cdl="cd ~/Programming/GitLab-repos/ && mcd"
- alias cds="cd ~/Programming/source/ && mcd"
# }}}
fi
@@ -345,28 +357,6 @@ device="desktop" # can be either "desktop" (default when empty), "server" or "an
# }}}
# Functions {{{
- ses () {
- sudo emerge -S "%$@"
- }
-
- # Execute multiple commands
- mexec () {
- for cmd in "${@[@]}"; do
- if ! [ -z "$cmd" ]; then
- $cmd
- fi
- done
- }
-
- # CD multiple times into subdirectories
- mcd () {
- for dir in "${@[@]}"; do
- if ! [ -z "$dir" ]; then
- cd $dir
- fi
- done
- }
-
# Run in the background
bgr () {
nohup sh -c "$@" 2>&1 &
@@ -378,9 +368,17 @@ device="desktop" # can be either "desktop" (default when empty), "server" or "an
pkill $@
bgr $@
}
-
+
+ if [[ device != "server" ]]; then
+ cdcomb () {
+ dir="$1"
+ if ! [ -z "$2" ]; then dir="$1$2" fi
+ cd "$dir"
+ }
+ fi
+
if [[ device != "server" && device != "android" ]]; then
-
+
if [[ -x "$(command -v vimx)" ]]; then
# Open vim with .vim-session file, if it exists and the vim command doesn't have any parameters
vim () {
@@ -400,13 +398,13 @@ device="desktop" # can be either "desktop" (default when empty), "server" or "an
grit add -p $parent -- $@
}
fi
-
+
if [[ -x "$(command -v nemo)" ]]; then
onemo() {
bgr "nemo ./"
}
fi
-
+
# Launch .desktop application (either full path or just name)
dela () {
name=$1
@@ -419,7 +417,7 @@ device="desktop" # can be either "desktop" (default when empty), "server" or "an
comm=($(awk -F= '$1=="Exec"{$1=""; print}' "$name"))
bgr "$comm"
}
-
+
fi
# }}}
@@ -429,3 +427,7 @@ device="desktop" # can be either "desktop" (default when empty), "server" or "an
# Added by scripts:
export PATH="/home/kamen/bin/Sencha/Cmd:$PATH"
+
+export NVM_DIR="$HOME/.nvm"
+# [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
+# [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion