[shell] outsource aliases to own file

This commit is contained in:
Marco Thomas
2022-11-04 00:51:53 +01:00
parent 15c7d751f8
commit 7f07f9715a
2 changed files with 101 additions and 109 deletions

View File

@@ -0,0 +1,65 @@
# zsh specific
if [[ "$SHELL" =~ "zsh$" ]]; then
alias -g G='| grep -i'
alias -g L='| less'
fi
# general
alias c='clear'
alias t='tmux a || tmux'
alias o='xdg-open' # to change a mime use: `xdg-mime default APPLICATION HANDLE`
alias gg='git grep $1'
alias tex='nix-shell ~/.dots/tex.nix'
alias mktex="latexmk -xelatex -shell-escape"
alias l='ls -lFh --color'
alias la='ls -lAFh --color'
alias ll='ls -l --color'
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias truecolor='curl -s https://raw.githubusercontent.com/JohnMorales/dotfiles/master/colors/24-bit-color.sh | bash'
alias nssh='SSH_AUTH_SOCK= ssh'
alias cpu='watch -n.1 "grep \"^[c]pu MHz\" /proc/cpuinfo"'
# nmcli
alias con='nmcli con'
alias conup='nmcli con up id'
alias condown='nmcli con down id'
alias conscan='nmcli dev wifi'
alias conedit='nm-connection-editor'
# functions
ocr() {
if [ -z $1 ]; then
echo "Please input a file."
return
fi
ocrmypdf -l deu+eng+jpn --output-type pdf $1 OCR_$1
}
# deprecated
# conservation() {
# location='/sys/bus/platform/drivers/ideapad_acpi/VPC2004:00/conservation_mode'
# if [ -z $1 ]; then
# cat $location
# elif [ $1 = '0' ] || [ $1 = '1' ]; then
# echo $1 | sudo tee $location
# else
# echo 'Invalid option'
# fi
# }
#
# power() {
# location='/sys/firmware/acpi/platform_profile'
# if [ -z $1 ]; then
# echo "Current:" $(cat $location)
# echo "Can be one of:" $(cat /sys/firmware/acpi/platform_profile_choices)
# elif [ $1 = 'low-power' ] || [ $1 = 'balanced' ] || [ $1 = 'performance' ]; then
# echo $1 | sudo tee $location
# else
# echo 'Invalid option'
# fi
# }

View File

@@ -35,80 +35,7 @@ case $TERM in
esac esac
# ============================== Aliases # ============================== Aliases
alias c='clear' source ~/.shellrc.alias
alias t='tmux a || tmux'
alias tex='nix-shell ~/.dots/tex.nix'
alias l='ls -lFh --color' #size,show type,human readable
alias la='ls -lAFh --color' #long list,show almost all,show type,human readable
alias ll='ls -l --color' #long list
alias rm='rm -i' # Ask before removal
alias cp='cp -i' # Ask before removal
alias mv='mv -i' # Ask before removal
alias -g G='| grep -i'
alias -g L='| less'
alias gg='git grep $1'
# tools
ocr() {
if [ -z $1 ]; then
echo "Please input a file."
return
fi
ocrmypdf -l deu+eng+jpn --output-type pdf $1 OCR_$1
}
conservation() {
location='/sys/bus/platform/drivers/ideapad_acpi/VPC2004:00/conservation_mode'
if [ -z $1 ]; then
cat $location
elif [ $1 = '0' ] || [ $1 = '1' ]; then
echo $1 | sudo tee $location
else
echo 'Invalid option'
fi
}
power() {
location='/sys/firmware/acpi/platform_profile'
if [ -z $1 ]; then
echo "Current:" $(cat $location)
echo "Can be one of:" $(cat /sys/firmware/acpi/platform_profile_choices)
elif [ $1 = 'low-power' ] || [ $1 = 'balanced' ] || [ $1 = 'performance' ]; then
echo $1 | sudo tee $location
else
echo 'Invalid option'
fi
}
replace() {
from=$1
to=$2
find -type f -exec sed -i -e "s/${from}/${to}/g" {} \;
}
alias o='xdg-open' # to change a mime use: `xdg-mime default APPLICATION HANDLE`
alias truecolor='curl -s https://raw.githubusercontent.com/JohnMorales/dotfiles/master/colors/24-bit-color.sh | bash'
alias nssh='SSH_AUTH_SOCK= ssh'
alias cpu='watch -n.1 "grep \"^[c]pu MHz\" /proc/cpuinfo"'
# nmcli
alias con='nmcli con'
alias conup='nmcli con up id'
alias condown='nmcli con down id'
alias conscan='nmcli dev wifi'
alias conedit='nm-connection-editor'
# troll
alias powershell='clear && PS1="windowsadm@powershell$ " bash'
alias mucdai='rm -rf'
alias bw='mv'
alias ='rm'
alias zg='ls'
alias ädrbes='chown'
alias erstelle='touch'
# ============================== Completion # ============================== Completion
unsetopt menu_complete # do not autoselect the first completion entry unsetopt menu_complete # do not autoselect the first completion entry
@@ -174,7 +101,7 @@ export FZF_DEFAULT_OPTS='
--color=marker:#5c6a72,spinner:#5c6a72,header:#5c6a72' --color=marker:#5c6a72,spinner:#5c6a72,header:#5c6a72'
## ripgrep-all ## ripgrep-all
# https://github.com/phiresky/ripgrep-all # needs https://github.com/phiresky/ripgrep-all
rga-fzf() { rga-fzf() {
RG_PREFIX="rga --files-with-matches" RG_PREFIX="rga --files-with-matches"
local file local file
@@ -189,7 +116,7 @@ rga-fzf() {
xdg-open "$file" xdg-open "$file"
} }
zle -N rga-fzf zle -N rga-fzf
bindkey '^G' "rga-fzf" bindkey '^S' "rga-fzf"
## fzf Bindings in zsh (C-r and C-f) ## fzf Bindings in zsh (C-r and C-f)
if [[ -x $(which fzf 2> /dev/null) ]] if [[ -x $(which fzf 2> /dev/null) ]]
@@ -299,8 +226,8 @@ zle -N fancy-ctrl-z
bindkey '^Z' fancy-ctrl-z bindkey '^Z' fancy-ctrl-z
# ============================== Source other definitions # ============================== Source other definitions
if [ -f ~/.zshrc_local ]; then if [ -f ~/.shellrc.local ]; then
source ~/.zshrc_local source ~/.shellrc.local
fi fi
if [ -e $HOME/.nix-profile/etc/profile.d/nix.sh ]; then . $HOME/.nix-profile/etc/profile.d/nix.sh; fi # added by Nix installer if [ -e $HOME/.nix-profile/etc/profile.d/nix.sh ]; then . $HOME/.nix-profile/etc/profile.d/nix.sh; fi # added by Nix installer