Browse Source

Make alias.sh POSIX compliant and add some functions to it, change $EDITOR to emacs

master
Riyyi 4 years ago
parent
commit
0433496338
  1. 4
      .config/zsh/.zprofile
  2. 19
      .config/zsh/.zshrc
  3. 41
      .scripts/alias.sh

4
.config/zsh/.zprofile

@ -10,7 +10,9 @@ export XDG_DATA_HOME="$HOME/.local/share"
mkdir -p "$XDG_CACHE_HOME/zsh"
# Editor
export EDITOR="vim"
export ALTERNATE_EDITOR=""
export EDITOR="emacsclient"
export VISUAL="emacsclient"
# Files
export GTK2_RC_FILES="$XDG_CONFIG_HOME/gtk-2.0/gtkrc"

19
.config/zsh/.zshrc

@ -85,6 +85,9 @@ alias df="df -h"
alias md="mkdir -p"
alias rm="rm -i"
alias se="sudoedit"
alias semacs="sudoedit"
alias e="$HOME/.scripts/alias.sh emacs"
alias emacs="$HOME/.scripts/alias.sh emacs"
alias v="vim --servername VIM"
alias vim="vim --servername VIM"
alias fuck='sudo $(fc -ln -1)'
@ -108,13 +111,13 @@ alias lzrc="source $ZDOTDIR/.zshrc"
alias install="sudo pacman -S --needed"
alias remove="sudo pacman -Rns"
alias update="sudo pacman -Syyu"
alias clean="sudo pacman -Rns $(pacman -Qtdq)"
alias clean='sudo pacman -Rns $(pacman -Qtdq)'
alias cache="sudo paccache -r -k 2"
alias depend="$HOME/.scripts/alias.sh depend"
# Programming
alias jdoc="$HOME/.scripts/alias.sh java-doc"
alias jr="$HOME/.scripts/alias.sh java-run"
alias jdoc="$HOME/.scripts/alias.sh java_doc"
alias jr="$HOME/.scripts/alias.sh java_run"
alias raspbian="$HOME/.scripts/alias.sh raspbian"
alias ser="pio device monitor -b 9600"
alias upl="pio run -t upload"
@ -139,8 +142,16 @@ alias vp="$HOME/.scripts/vimplugin.sh"
alias mpvshuffle="$HOME/.scripts/mpv.sh shuffle"
# Other
alias len="xclip -o | wc -m"
alias length="rofi -dmenu -i -p 'String length' -lines 0 | tr -d '\n' | wc -m"
alias p="$HOME/.scripts/alias.sh pastebin"
alias stream="$HOME/.scripts/alias.sh stream"
alias weather="curl -s 'https://wttr.in/dordrecht?q&n&p' | head -n -3"
alias workbench="GDK_SCALE=1 GDK_DPI_SCALE=1 mysql-workbench > /dev/null 2>&1 & disown"
alias ytaudio="youtube-dl -f bestaudio -x --audio-format mp3"
alias ytdl="youtube-dl -f bestvideo+bestaudio"
alias ytaudio="youtube-dl -f bestaudio/best -x --audio-format mp3"
zsh="/usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
[ -f "$zsh" ] && source "$zsh"; unset zsh
[ -f "$ZDOTDIR/.zshrc_extended" ] && source "$ZDOTDIR/.zshrc_extended"

41
.scripts/alias.sh

@ -1,15 +1,24 @@
#!/bin/bash
#!/bin/sh
emacs() {
# Create new frame if (there isnt one || no file specified)
if [ -z "$(pgrep emacsclient)" ] || [ "$1" = "" ]; then
emacsclient -a '' -c "$@" > /dev/null 2>&1 &
else
emacsclient -a '' "$@" > /dev/null 2>&1 &
fi
}
depend() {
pactree -u -d 1 $1 | tail -n +2
pactree -u -d 1 "$1" | tail -n +2 | sort
}
java-doc() {
java_doc() {
mkdir -p './doc';
javadoc -d './doc' *.java
javadoc -d './doc' -- *.java
}
java-run() {
java_run () {
mkdir -p './out';
javac -d './out' "$1.java";
java -cp './out' "$1"
@ -20,8 +29,28 @@ raspbian() {
if ! ip a show usb0 | grep -q 'inet6'; then
sudo dhcpcd usb0
fi
ssh -6 pi@$(avahi-resolve-host-name raspberrypi.local | awk '{ print $2 }')%usb0
ssh -6 pi@"$(avahi-resolve-host-name raspberrypi.local | awk '{ print $2 }')"%usb0
sudo systemctl stop avahi-daemon.service
}
# $1 = find, $2 = list, $3 = list separator
in_list() {
[ -z "$1" ] || [ -z "$2" ] && return 1
if ! echo "$2" | awk -v m="^$1$" -v RS="${3:-' '}" '$0 ~ m { exit 1 }'; then
return 0
else
return 1
fi
}
pastebin() {
echo "$1" | curl -F 'f:1=<-' ix.io
}
stream() {
[ -z "$2" ] && QUALITY="720p" || QUALITY="$2"
streamlink --player mpv "https://twitch.tv/$1" "$QUALITY" > /dev/null 2>&1 &
}
"$@"

Loading…
Cancel
Save