Skip to content

Instantly share code, notes, and snippets.

@SuCicada
Last active April 2, 2021 04:11
Show Gist options
  • Select an option

  • Save SuCicada/3a4af1d1215b75545695262c4480482c to your computer and use it in GitHub Desktop.

Select an option

Save SuCicada/3a4af1d1215b75545695262c4480482c to your computer and use it in GitHub Desktop.

Revisions

  1. SuCicada revised this gist Apr 2, 2021. No changes.
  2. SuCicada created this gist Apr 2, 2021.
    83 changes: 83 additions & 0 deletions .profile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,83 @@
    # ~/.profile: executed by the command interpreter for login shells.
    # This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
    # exists.
    # see /usr/share/doc/bash/examples/startup-files for examples.
    # the files are located in the bash-doc package.

    # the default umask is set in /etc/profile; for setting the umask
    # for ssh logins, install and configure the libpam-umask package.
    #umask 022

    # if running bash
    if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
    . "$HOME/.bashrc"
    fi
    fi

    # set PATH so it includes user's private bin if it exists
    if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
    fi

    # set PATH so it includes user's private bin if it exists
    if [ -d "$HOME/.local/bin" ] ; then
    PATH="$HOME/.local/bin:$PATH"
    fi

    export DISPLAY=win.ip:0

    #utils
    source utils.sh
    winip(){
    echo `cat /etc/resolv.conf | grep nameserver | awk '{print $2}'`
    }
    #export TERM=xterm-color


    sethosts(){
    hosts=$1
    ip=$2
    host=$3
    tmp=~/share/hosts-`date +%s`
    #echo grep $host $hosts \| wc -l
    # if [ `grep $host $hosts | wc -l` -gt 0 ];then
    cp $hosts $tmp
    dos2unix -q $tmp
    sed -i "/${host}/d" $tmp
    # else
    # echo $hosts
    # fi
    echo '' >> $tmp
    echo "$ip $host" >> $tmp
    sed -i '/^\s*$/d' $tmp
    #cat $tmp | sudo tee $hosts
    sudo cp $tmp $hosts
    echo "$ip $host --> $hosts"
    }
    wsl_ip=`ifconfig eth0 | awk '/inet /{print substr($2,1)}'`
    wsl_host=ubuntu.wsl2
    wsl_hosts=/etc/hosts
    win_ip=`winip`
    win_host=win.ip
    win_hosts=/mnt/c/Windows/System32/drivers/etc/hosts
    echo sucicada | sudo -S -v
    sethosts $win_hosts $wsl_ip $wsl_host
    sethosts $win_hosts $win_ip $win_host
    sethosts $wsl_hosts $wsl_ip $wsl_host
    sethosts $wsl_hosts $win_ip $win_host

    sudo service ssh start
    if test -f /run/nologin;then
    sudo mv /run/nologin /run/nologin.bak
    fi
    echo

    #export PATH=$PATH:"/mnt/c/Program Files/qemu"

    PS1="\[\033[1;32;01m\]\u\[\033[00m\]\[\033[1;34;01m\]@\[\033[00m\]\[\033[1;32;01m\]\h\[\033[00m\]\[\033[34;01m\]:\[\033[00m\]\[\033[33;01m\]\w\[\033[00m\]\[\033[31;01m\] \$\[\033[37;00m\] "

    function catjp(){
    cat $1 | iconv -f shift-jis -t UTF-8 -o $1
    }