From eb1dbbb8be24a284777dc341c59841051e68045a Mon Sep 17 00:00:00 2001 From: Mehdi Sadeghi Date: Sun, 16 May 2021 20:39:05 +0200 Subject: Add basic (posix) shell. --- .bashrc | 26 ++++++++++++++++++++++++++ .env | 9 +++++++++ .inputrc | 8 ++++---- .local/bin/prompt | 8 ++++++++ .profile | 23 +++++++++++++++++++++++ .zshrc | 2 ++ 6 files changed, 72 insertions(+), 4 deletions(-) create mode 100644 .bashrc create mode 100644 .env create mode 100755 .local/bin/prompt create mode 100644 .profile diff --git a/.bashrc b/.bashrc new file mode 100644 index 0000000..f8f2fa3 --- /dev/null +++ b/.bashrc @@ -0,0 +1,26 @@ +PS1="[\u@\h:\W]> " + +if [ -z "${SSH_AGENT_PID}" ]; then + if ! [ -e /tmp/ssh-agent-$USER ] + then + ssh-agent 2>/dev/null >/tmp/ssh-agent-$USER + fi + . /tmp/ssh-agent-$USER >/dev/null +fi + +# Aliases +# `githome` alias is a trick to avoid having git prompt when working +# in different directories of my home folder. I simply rename `.git` +# folder to `.githome` and use the following alias to interact with it. +# On new systems I only need to do the following: +# cd ~ +# git init +# git remote add origin git@git.sr.ht:~mehdix/dotfiles +# or +# git remote add origin https://git.sr.ht/~mehdix/dotfiles +# git fetch +# git checkout -f master +# mv .git .githome +alias githome='git --git-dir ~/.githome --work-tree ~' + +[ -f ~/.fzf.bash ] && source ~/.fzf.bash \ No newline at end of file diff --git a/.env b/.env new file mode 100644 index 0000000..a184ed8 --- /dev/null +++ b/.env @@ -0,0 +1,9 @@ +PS1='$(prompt)' + +if [ -z "${SSH_AGENT_PID}" ]; then + if ! [ -e /tmp/ssh-agent-$USER ] + then + ssh-agent 2>/dev/null >/tmp/ssh-agent-$USER + fi + . /tmp/ssh-agent-$USER >/dev/null +fi \ No newline at end of file diff --git a/.inputrc b/.inputrc index c540473..2e98173 100644 --- a/.inputrc +++ b/.inputrc @@ -1,5 +1,5 @@ # Key bindings, up/down arrow searches through history -"\e[A": history-search-backward -"\e[B": history-search-forward -"\eOA": history-search-backward -"\eOB": history-search-forward +"\e[A": history-subscring-search-backward +"\e[B": history-subscring-search-forward +"\eOA": history-subscring-search-backward +"\eOB": history-subscring-search-forward diff --git a/.local/bin/prompt b/.local/bin/prompt new file mode 100755 index 0000000..90e3a17 --- /dev/null +++ b/.local/bin/prompt @@ -0,0 +1,8 @@ +#!/bin/sh +BRANCH=$(git branch --show-current 2>/dev/null) +BRANCH=$(test -d .git && test -n $BRANCH && echo "($BRANCH)") +PROMPT="[$(hostname):$(basename "$PWD")$BRANCH]" +case $(id -u) in +0) echo "$PROMPT# " ;; +*) echo "$PROMPT$ " ;; +esac diff --git a/.profile b/.profile new file mode 100644 index 0000000..25b457c --- /dev/null +++ b/.profile @@ -0,0 +1,23 @@ +export ENV=~/.env +export LANG=en_US.UTF-8 +export LC_TIME=de_DE.UTF-8 +export EDITOR=vim +export TERM=xterm +export HISTSIZE=65535 +# autojump needs this +export PROMPT_COMMAND="history -a" + +export PATH=$HOME/.local/bin:$PATH +export PATH=$HOME/.local/bin/`hostname`:$PATH +export PATH=$HOME/.local/bin/`uname -m`:$PATH +export PATH=$HOME/.cargo/bin:$PATH +export GOPATH="$HOME/.local/share/go" +export PATH=$GOPATH/bin:$PATH +export MAKEFLAGS=-j`lscpu | grep '^CPU(s):' | awk -F' ' '{ print $2 }'` +export CFLAGS="-O2 -pipe -march=native" +export CXXFLAGS="${CFLAGS}" +# Sway compatiblity https://github.com/swaywm/sway/issues/595 +export _JAVA_AWT_WM_NONREPARENTING=1 + +[ $SHELL = "/bin/bash" ] && [ -f ~/.bashrc ] && . ~/.bashrc +[ -e .config/$(hostname).profile ] && . .config/$(hostname).profile \ No newline at end of file diff --git a/.zshrc b/.zshrc index 7624b34..9a53147 100644 --- a/.zshrc +++ b/.zshrc @@ -65,3 +65,5 @@ fi # mv .git .githome alias githome='git --git-dir ~/.githome --work-tree ~' + +[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh -- cgit v1.2.3