[shell] outsource aliases to own file
This commit is contained in:
65
files/shell/.shellrc.alias
Normal file
65
files/shell/.shellrc.alias
Normal 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
|
||||
# }
|
||||
@@ -35,80 +35,7 @@ case $TERM in
|
||||
esac
|
||||
|
||||
# ============================== Aliases
|
||||
alias c='clear'
|
||||
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 lö='rm'
|
||||
alias zg='ls'
|
||||
alias ädrbes='chown'
|
||||
alias erstelle='touch'
|
||||
source ~/.shellrc.alias
|
||||
|
||||
# ============================== Completion
|
||||
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'
|
||||
|
||||
## ripgrep-all
|
||||
# https://github.com/phiresky/ripgrep-all
|
||||
# needs https://github.com/phiresky/ripgrep-all
|
||||
rga-fzf() {
|
||||
RG_PREFIX="rga --files-with-matches"
|
||||
local file
|
||||
@@ -189,7 +116,7 @@ rga-fzf() {
|
||||
xdg-open "$file"
|
||||
}
|
||||
zle -N rga-fzf
|
||||
bindkey '^G' "rga-fzf"
|
||||
bindkey '^S' "rga-fzf"
|
||||
|
||||
## fzf Bindings in zsh (C-r and C-f)
|
||||
if [[ -x $(which fzf 2> /dev/null) ]]
|
||||
@@ -299,8 +226,8 @@ zle -N fancy-ctrl-z
|
||||
bindkey '^Z' fancy-ctrl-z
|
||||
|
||||
# ============================== Source other definitions
|
||||
if [ -f ~/.zshrc_local ]; then
|
||||
source ~/.zshrc_local
|
||||
if [ -f ~/.shellrc.local ]; then
|
||||
source ~/.shellrc.local
|
||||
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
|
||||
Reference in New Issue
Block a user