Advertisement
arkanon

/etc/profile

Aug 4th, 2013
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # /etc/profile
  2.  
  3. # system-wide .profile file for Bourne (and compatible) Shells.
  4. #
  5. # Arkanon <arkanon@lsd.org.br>
  6. # 2013/08/02 (Sex) 13:48:22 (BRS)
  7. # 2013/08/01 (Thu) 14:17:29 (BRS)
  8. # 2013/07/31 (Qua) 16:43:54 (BRS)
  9. # 2013/07/24 (Qua) 15:13:05 (BRS)
  10. # 2013/05/10 (Sex) 01:34:31 (BRS)
  11. # 2012/05/18 (Sex) 18:41:47 (BRS)
  12. #
  13. # 1st revision: 1993, @euler.mat.ufrgs.br
  14. #
  15. # O conteudo abaixo estara disponivel em dois arquivos: /etc/profile e /etc/bash.bashrc
  16. # Quatro ambientes o utilizarao: terminais no modo login shell, screen, ssh e scp.
  17. #   para os terminais, basta o arquivo profile.
  18. #   para o screen, devem existir os dois arquivos.
  19. #
  20. # Dependencias
  21. #  - screen
  22. #  - colordiff
  23. #  - most
  24. #  - libtrash.so.3.2
  25.  
  26. echo "$TERM" | grep -q "dumb" ||
  27. {
  28.  
  29.  
  30.  
  31.   export TTY=$(tty)
  32.  
  33.   sw()
  34.   {
  35.     one='screen -wipe | grep -v There | sort -t. -k2'
  36.     [ $(id -u) = 0 ] && ls -1 /var/run/screen/ | cut -d- -f2 | grep -v $USER | while read user; do eval sudo -u $user $one; done
  37.     eval $one
  38.     echo
  39.   }
  40.  
  41.   cat << EOT
  42.  
  43.         TTY: $TTY
  44.        TERM: $TERM
  45. BASH_SOURCE: ${BASH_SOURCE[0]}
  46. $(sw)
  47.  
  48. EOT
  49.  
  50.   if ! echo $TERM | grep -q "screen"
  51.   then
  52.  
  53.     N=30
  54.     echo -n "Starting screen in $N seconds, press C to Cancel, Q to Quit or any other key to start immediately... ";
  55.     for i in $(eval echo {$N..1})
  56.     do
  57.       echo -n "$i "
  58.       read -n 1 -t 1 -s key && break
  59.     done
  60.     key=$(echo $key | tr A-Z a-z)
  61.  
  62.     case "$key" in
  63.  
  64.       "c" )
  65.             echo -e "canceled.\n"
  66.             ;;
  67.  
  68.       "q" )
  69.             echo -n "quiting."
  70.             exit
  71.             ;;
  72.  
  73.         * )
  74.             detached=$(screen -ls | grep detached | sort)
  75.                first=$(echo "$detached" | head -n1)
  76.             [ "$detached" ] && screen -r $first || screen -R -t $(tty|cut -d/ -f3-|tr / -)
  77.             exit
  78.             ;;
  79.  
  80.     esac
  81.  
  82.   fi
  83.  
  84.  
  85.  
  86. # [additional scripts]
  87.  
  88. # [ "$BASH" ] && [ -f /etc/bash.bashrc ] && . /etc/bash.bashrc
  89.  
  90.   for profile_script in /etc/profile.d/*.sh
  91.   do
  92.     [ -x $profile_script ] && . $profile_script
  93.   done
  94.   unset profile_script
  95.  
  96.  
  97.  
  98. # [environment variables]
  99.  
  100.                                FS=/fs
  101.  
  102.   export               LD_PRELOAD=/fs/lib/libtrash.so.3.2
  103.  
  104.                              PATH=$FS/bin:/usr/local/bin:/usr/bin:/bin:/usr/games:$HOME/bin
  105.                   LD_LIBRARY_PATH=$FS/lib:$HOME/lib
  106. #                          CDPATH=.:auto/clip/image/fotos/:/auto/i/.soft/common/:$FS/share/:/home/
  107.                           MANPATH=$FS/man:/usr/local/share/man:/usr/share/man
  108.  
  109.                              PATH=$PATH:/export/data/src/depot_tools
  110.  
  111.   if [ $(id -u) = 0 ]
  112.   then
  113.                              PATH=$FS/sbin:/usr/local/sbin:/usr/sbin:/sbin:$PATH
  114.   else
  115.                              PATH=$PATH:.
  116.                   LD_LIBRARY_PATH=$LD_LIBRARY_PATH:.
  117.   fi
  118.  
  119.   export                 HOSTNAME=$(cat /etc/hostname)
  120.   export                 WWW_HOME=http://www.google.com/
  121. # export                 LYNX_CFG=~/.lynxrc
  122.  
  123. # locale -a
  124.   loc="pt_BR"
  125.   utf=".utf8"
  126. # sudo locale-gen en_US$utf
  127. # sudo dpkg-reconfigure locales
  128.  
  129.   unset LC_ALL # Its value will override all the LC_* variable (but not LANG). After setting LC_ALL, modifications to any LC_* variables are not permitted.
  130.                # In general, it is then recommended to leave LC_ALL unset, set instead LANG, and change individual LC_* variables to suit your needs.
  131.  
  132.   export                 LANGUAGE="$loc$utf"
  133.   export                     LANG="$loc$utf" # Set the value of all LC_* variables which are not explicitely set (those already set are not changed).
  134.                                              # Also, any LC_* variable can be modified after setting LANG.
  135.  
  136.   export               LC_ADDRESS="$loc$utf"
  137.   export               LC_COLLATE="C"        # Collation order used for comparing and sorting
  138.   export        LC_IDENTIFICATION="$loc$utf"
  139.   export           LC_MEASUREMENT="$loc$utf"
  140.   export              LC_MONETARY="$loc$utf" # Monetary formats
  141.   export                  LC_NAME="$loc$utf"
  142.   export                 LC_PAPER="$loc$utf" # Paper format
  143.   export             LC_TELEPHONE="$loc$utf"
  144.   export                 LC_CTYPE="$loc$utf" # Character classification and case conversion. Also indicates the language which should be used with XIM
  145.   export              LC_MESSAGES="$loc$utf" # Formats of informative and diagnostic messages and interactive responses (also for graphical user interfaces)
  146.   export               LC_NUMERIC="$loc$utf" # Non-monetary numeric formats
  147.   export                  LC_TIME="$loc$utf" # Date and time formats
  148.   export                       TZ="$FS/etc/tz/Brazil/East"
  149.  
  150. # locale -m
  151.   charset=UTF-8
  152. # charset=ISO-8859-1
  153.   export                     LESS=-MRS      # NF
  154.   export                  LESSKEY=/etc/lesskey
  155.   export                 LESSOPEN="|lesspipe.sh %s"
  156.   export              LESSCHARSET=$charset
  157.   export         GROFF_TYPESETTER=$charset
  158.   export          LESS_TERMCAP_mb=$'\e[01;31m'     # red          begin blinking
  159.   export          LESS_TERMCAP_md=$'\e[01;33m'     # yellow       begin bold
  160.   export          LESS_TERMCAP_me=$'\e[0m'         #              end   mode
  161.   export          LESS_TERMCAP_so=$'\e[01;44;33m'  # blue/yellow  begin standout-mode (info box)
  162.   export          LESS_TERMCAP_se=$'\e[0m'         #              end   standout-mode
  163.   export          LESS_TERMCAP_us=$'\e[01;32m'     # green        begin underline
  164.   export          LESS_TERMCAP_ue=$'\e[0m'         #              end   underline
  165.   unset charset
  166.  
  167.   export                IGNOREEOF=2 # logouts with ^D pressed 3 times
  168. # export                    TMOUT=300   # automaticaly logs out if idle is 300s (0 for never)
  169.   export             PERL_BADLANG=0
  170. # export        ALSA_OUTPUT_PORTS=128:0
  171.  
  172. # export                 RCX_PORT=/dev/ttyS0
  173.  
  174. # export                 MANPAGER="most -s"
  175.   export                    PAGER="bash -c \"col -b -x | $FS/bin/vi -R -S /etc/vim/man.vim -\"" # <http://vim.wikia.com/wiki/Using_vim_as_a_man-page_viewer_under_Unix>
  176.  
  177.   {
  178.     export                 HISTFILE=~/.history
  179.     export             HISTFILESIZE=50000
  180.     export                 HISTSIZE=50000
  181.   } &> /dev/null
  182.  
  183.   export           HISTTIMEFORMAT="%Y/%m/%d %a %T %Z  "
  184.   export command_oriented_history=1             # bash attempts to save all lines of a multiple-line command in the same history entry. This allows easy re-editing of multi-line commands
  185.   export           PROMPT_COMMAND="history -a"          # append the "new" history lines (history lines entered since the beginning of the current bash session) to the history file.
  186. # export           PROMPT_COMMAND="history -n; $PROMPT_COMMAND" # read the history lines not already read from the history file into the current history list. These are lines appended to the history file since the beginning of the current bash session.
  187. # export               HISTIGNORE="pwd:ls:ls -ltr:"     # patterns used to decide which command lines should be saved on the history list
  188. # export              HISTCONTROL="ignoredups"          # values controlling how commands are saved on the history list
  189.                 # ignorespace           # lines which begin with a space character are not saved in the history list
  190.                 # ignoredups            # lines matching the previous history entry to not be saved
  191.                 # ignoreboth            # shorthand for ignorespace and ignoredups
  192.                 # erasedups         # all previous lines matching the current line to be removed from the history list before that line is saved.
  193.  
  194.   [ "$DISPLAY" ] && xhost +SI:localuser:root
  195.  
  196.   shopt -s checkwinsize         # bash checks the window size after each command and, if necessary, updates the values of LINES and COLUMNS
  197.   shopt -s histappend           # the history list is appended to the file named by the value of the HISTFILE variable when the shell exits, rather than overwriting the file
  198.   shopt -s cmdhist          # bash attempts to save all lines of a multiple-line command in the same history entry. This allows easy re-editing of multi-line commands
  199.   shopt -s lithist          # If the cmdhist option is enabled, multi-line commands are saved to the history with embedded newlines rather than using semicolon separators where possible
  200.  
  201.   # if readline is being used
  202.   shopt -s hostcomplete         # bash will attempt to perform hostname completion when a word containing a @ is being completed. This is enabled by default
  203.   shopt -s histreedit           # a user is given the opportunity to re-edit a failed history substitution
  204.   shopt -s histverify           # the results of history substitution are not immediately passed to the shell parser. Instead, the resulting line is loaded into the readline editing buffer, allowing further modification
  205.   shopt -s no_empty_cmd_completion  # bash will not attempt to search the PATH for possible completions when completion is attempted on an empty line
  206.  
  207.   # Set some vars read-only
  208.   typeset -r HISTFILE HISTFILESIZE HISTSIZE
  209.  
  210.   umask 0002                # default mode = 0664/0775
  211. # biff  y
  212.   mesg  y
  213. # stty  echo                # commente because locks WM startup in X
  214.  
  215.   ulimit -c 0               # disable coredumps creation
  216. # ulimit -u 64              # limits the maximum number of processes available to a single user
  217.  
  218.   set -o noclobber          # prevents overwrite of files with cp
  219.   set -o notify             # report the status of terminated background jobs immediately
  220.  
  221.   export NWS=$'\x0A'$'\x0D'     # no whitespace :=  line_feed   carriage_return
  222.   export  WS=$'\x20'$'\x09'     #    whitespace :=  space       tab
  223.   export DEF=${WS}${NWS}        #   default ifs :=  whitespace  no_whitespace
  224.  
  225.   # If the user doesn't have a .inputrc, use the one in /etc.
  226.   [ -r "$HOME/.inputrc" ] || export INPUTRC=/etc/inputrc
  227.  
  228.   # I had problems with the backspace key using 'eval tset' instead of 'TERM=',
  229.   # but you might want to try it anyway instead of the section below it.  I
  230.   # think with the right /etc/termcap it would work.
  231.   # eval $(tset -sQ "$TERM")
  232.  
  233.   # Set TERM to linux for unknown type or unset variable:
  234.   [ "$TERM" = "" -o "$TERM" = "unknown" ] && TERM=linux
  235.  
  236. # EDITOR="emacs"
  237. # EDITOR="gmacs"
  238. # EDITOR="$FS/bin/edit"
  239. # EDITOR="vi"
  240.  
  241.  
  242.  
  243. # [ls_options]
  244.   ls --help 2>&1 | grep -q group-directories-first && LS_GDF="--group-directories-first"
  245.   LS_OPTIONS='-lapbviT0 --color=always --time-style="+%Y/%m/%d %a %T %Z"'
  246.   SL_OPTIONS='-lapbvT0  --color=always --time-style=+'
  247.  
  248. # [ls_colors]
  249.   eval $(dircolors -b)
  250.   [ -f /etc/DIR_COLORS   ] && eval $(dircolors -b /etc/DIR_COLORS)
  251.   [ -f $HOME/.dir_colors ] && eval $(dircolors -b $HOME/.dir_colors)
  252.  
  253.  
  254.  
  255. # [functions]
  256.  
  257.   ps()
  258.   {
  259.     ps=/bin/ps
  260.     format="o start,tty,user,rss,pid,cmd"
  261.     if [ $# = 0 ]
  262.     then
  263.       $ps fwwx $format
  264.     else
  265.       [ "$1" = a ] && $ps fwwxa $format || $ps fww $format U $1
  266.     fi
  267.   }
  268.  
  269. # # replaced with $FS/bin/vi because of $PAGER variable
  270. # vi()
  271. # {
  272. #   args="" && [ "$*" ] && args=$( for i in $(seq $#); do eval echo \\\"\${$i}\\\"; done )
  273. #   { vi=$(which vim) && [ "$DISPLAY" ] && xping -n1 && which gvim && vi="gvim"; } &> /dev/null
  274. # # { vi=$(which vim) && [ "$DISPLAY" ]              && which gvim && vi="gvim"; } &> /dev/null
  275. #   eval $vi $args 2>> ~/.xsession-errors
  276. # }
  277. # export -f vi
  278.  
  279.   sl()
  280.   {
  281.     BLOCK_SIZE=\'1 ls $SL_OPTIONS $LS_GDF $* | cut -c12- | sed "/^$/d"
  282.   # LC_NUMERIC=en_US$utf BLOCK_SIZE=\'1 ls $SL_OPTIONS $LS_GDF $* | cut -c12- | sed "/^$/d"
  283.   }
  284.  
  285.   sla()
  286.   {
  287.     BLOCK_SIZE=\'1 ls $SL_OPTIONS         $* | cut -c12- | sed "/^$/d"
  288.   # LC_NUMERIC=en_US$utf BLOCK_SIZE=\'1 ls $SL_OPTIONS         $* | cut -c12- | sed "/^$/d"
  289.   }
  290.  
  291.   prompt()
  292.   {
  293.  
  294.     local   black="\[\e[1;30m\]"
  295.     local     red="\[\e[1;31m\]"
  296.     local   green="\[\e[1;32m\]"
  297.     local  yellow="\[\e[1;33m\]"
  298.     local    blue="\[\e[1;34m\]"
  299.     local magenta="\[\e[1;35m\]"
  300.     local    cyan="\[\e[1;36m\]"
  301.     local   white="\[\e[1;37m\]"
  302.     local     off="\[\e[0m\]"
  303.  
  304.     local  c__def=$red
  305.     local  c_numb=$red
  306.     local  c_user=$green
  307.     local  c_host=$yellow
  308.     local  c__tty=$cyan
  309.     local  c_path=$white
  310.  
  311.     local char at tat
  312.  
  313.     if [ "$(id -u)" = "0" ]
  314.     then
  315.       char="#"
  316.         at=""
  317.        tat=""
  318.     else
  319.       char="$"
  320.         at="$c_user\u$c__def@"
  321.        tat="\u@"
  322.     fi
  323.  
  324.     local  ab='['
  325.     local  fe=']'
  326. #   local tty=t$(tty | awk -F "tty" '{print$2}') && [ "$tty" = "t" ] && tty=p$(tty | awk -F "/" '{print$NF}')
  327.     local tty=$(tty | cut -d/ -f3-)
  328.     # \!  history number of current command
  329.     # \$  # for UID=0  and  $ othewise
  330.     # \h  hostname
  331.     # \s  name of shell
  332.     # \t  time
  333.     # \u  username
  334.     # \w  working directory
  335.     # \W  basename of working direktory
  336.     local  title="\[\e]0;$tat\h$ab$tty$fe\w\a\]"
  337.     local prompt="$c_numb\! $at$c_host\h$c__def$ab$c__tty$tty$c__def$fe$c_path\w$c__def$char$off "
  338.     echo "$TERM" | grep -qi xterm && echo "$title$prompt" || echo "$prompt"
  339.  
  340.   }
  341.  
  342.   PS1=$(prompt)
  343.  
  344.  
  345.  
  346.   export FS PATH CDPATH MANPATH LD_LIBRARY_PATH TERM VISUAL EDITOR PS1 LS_OPTIONS SL_OPTIONS LS_GDF
  347.  
  348.  
  349.  
  350. # [aliases]
  351.  
  352. # unalias d
  353. # unalias dir
  354. # unalias ls
  355. # unalias mc
  356. # unalias v
  357. # unalias vdir
  358.  
  359. # alias     l="LC_NUMERIC=en_US$utf BLOCK_SIZE=\'1 ls $LS_OPTIONS $LS_GDF"
  360. # alias    la="LC_NUMERIC=en_US$utf BLOCK_SIZE=\'1 ls $LS_OPTIONS"
  361.   alias     l="BLOCK_SIZE=\'1 ls $LS_OPTIONS $LS_GDF"
  362.   alias    la="BLOCK_SIZE=\'1 ls $LS_OPTIONS"
  363.   alias watch="watch -cbn1"
  364.   alias cgrep="grep --color=always"
  365.   alias     h="history"
  366.   alias    du="time du -chs"
  367.   alias    df="df -haT"
  368.   alias    wt="wordtrans"
  369.   alias  time="/usr/bin/time -f 'ELAPSED TIME: %E'"
  370.   alias  lynx="lynx -cfg=$HOME/.lynxrc"
  371.  
  372. # alias   put="nqc -d"
  373. # alias   run="nqc -run"
  374. # alias  wake="nqc -sleep 10"
  375. # alias   off="nqc -sleep 1"
  376. # alias  firm="nqc -firmfast /auto/share/Areas/Robotica/nqc/firmware/firm.lgo"
  377.  
  378.  
  379.  
  380.   # [sudo hint]
  381.   if [ ! -e $HOME/.sudo_as_admin_successful ]
  382.   then
  383.     case " $(groups) " in *\ admin\ *)
  384.     if [ -x /usr/bin/sudo ]
  385.     then
  386.       cat << EOF
  387.         To run a command as administrator (user "root"), use "sudo <command>".
  388.         See "man sudo_root" for details.
  389. EOF
  390.     fi
  391.     esac
  392.   fi
  393.  
  394.   # if the command-not-found package is installed, use it
  395.   if [ -x /usr/lib/command-not-found ]
  396.   then
  397.     command_not_found_handle()
  398.     {
  399.       # check because c-n-f could've been removed in the meantime
  400.       if [ -x /usr/lib/command-not-found ]
  401.       then
  402.         python /usr/lib/command-not-found -- $1
  403.         return $?
  404.       else
  405.         return 127
  406.       fi
  407.     }
  408.   fi
  409.  
  410.  
  411.  
  412. # [LWD - Last Working Directory]
  413.  
  414. # Em 19 de março de 2010 11:50, Julio C. Neves <julio.neves@gmail.com> escreveu:
  415. # > Bah Tchê,
  416. # > se eu entendi bem, em tempo de login vc quer voltar para o diretório em que
  417. # > estava qdo deu logout. se for isso coloque a seguinte linha no ~/.bashrc:
  418. #
  419. # Oi, Julio. Obrigado pela dica! :-)
  420. #
  421. # Inicialmente era exatamente isso que eu queria.
  422. #
  423. # > cd $(cat ~/.lwd 2> /dev/null)
  424. # > trap "echo $PWD > ~/.lwd" 0 15
  425. #
  426. # A sua solucao tem a simplicidade poetica dos bons scripts bash :-) ; com ela percebi que minha solucao inicial nao resolvia o problema proposto.
  427. #
  428. # [CUT, inclusive o aperfeicoamento da solucao acima :-p]
  429. #
  430. # Mas agora, alem de
  431. #
  432. # (1) nao havendo sessoes abertas, fazer a primeira nova sessao voltar para o ultimo (L) diretorio de trabalho (WD) da ultima sessao shell fechada,
  433. #
  434. # resolvi querer MAIS 2 coisas :-p
  435. #
  436. # (2) fazer as novas sessoes iniciarem no LWD definido no conjunto de sessoes abertas, ignorando as sessoes que vao sendo fechadas, ate que se feche a
  437. #     ultima;
  438. #
  439. # (3) implementar um caracter especial (no estilo do - e do ~) que diga ao comando cd para entrar nesse LWD, permitindo que as sessoes abertas "conversem"
  440. #     nesses termos de LWD.
  441. #
  442. # Juntando as nossas 2 solucoes, cheguei a essa:
  443. #
  444. # --
  445. #
  446. # lwd_cd()
  447. # {
  448. #   local LWD=$1
  449. #   [ "$LWD" = : ] && LWD=$(cat ~/.lwd 2> /dev/null)
  450. #   cd "${LWD:-$HOME}" && pwd >| ~/.lwd
  451. # }
  452. #
  453. # echo $$ >> ~/.lwp
  454. #
  455. # trap 'echo "$(grep -wv $$ ~/.lwp 2> /dev/null)" >| ~/.lwp; grep -qE "[0-9]" ~/.lwp || cd .' 0 15
  456. #
  457. # alias cd="lwd_cd"
  458. #
  459. # cd :
  460. #
  461. # --
  462. #
  463. # O que acontece aí?
  464. #
  465. # <http://en.wikipedia.org/wiki/Path_%28computing%29#Representations_of_paths_by_operating_system_and_shell>
  466. #
  467. # Colocando o codigo acima em algum dos arquivos de inicializacao do bash, ate onde eu pude testar, as 3 condicoes estipuladas sao satisfeitas.
  468. #
  469. # E SIM, eu percebi que PODE haver concorrencia na hora de gravar o arquivo ~/.lwp, mas nao me preocupei com essa possibilidade AINDA, hehe. Ja
  470. # vi que fatalmente vou cair no uso dos fifo's de novo...
  471. #
  472. # E a minha pergunta continua: voces tem alguma sugestao para simplificar o algoritmo acima, mantendo agora as 3 condicoes?
  473. #
  474. # A-bash-os, (puts, essa foi triste... :-p)
  475.  
  476. # Signal     Value      Acti   Comment
  477. # --------   --------   ----   -------
  478. #                0      n/a    Exit code indicates if a signal may be sent
  479. # SIG HUP        1      Term   Hangup detected on controlling terminal or death of controlling process
  480. # SIG INT        2      Term   Interrupt from keyboard
  481. # SIG QUIT       3      Core   Quit from keyboard
  482. # SIG ILL        4      Core   Illegal Instruction
  483. # SIG TRAP       5      Core   Trace/breakpoint trap
  484. # SIG ABRT       6      Core   Abort signal from abort(3)
  485. # SIG BUS    10  7 10   Core   Bus error (bad memory access)
  486. # SIG FPE        8      Core   Floating point exception
  487. # SIG KILL       9      Term   Kill signal
  488. # SIG SEGV      11      Core   Invalid memory reference
  489. # SIG PIPE      13      Term   Broken pipe: write to pipe with no readers
  490. # SIG ALRM      14      Term   Timer signal from alarm(2)
  491. # SIG TERM      15      Term   Termination signal
  492. # SIG USR1   30 10 16   Term   User-defined signal 1
  493. # SIG USR2   31 12 17   Term   User-defined signal 2
  494. # SIG CHLD   20 17 18   Ign    Child stopped or terminated
  495. # SIG CONT   19 18 25   Cont   Continue if stopped
  496. # SIG STOP   17 19 23   Stop   Stop process
  497. # SIG TSTP   18 20 24   Stop   Stop typed at tty
  498. # SIG TTIN   21 21 26   Stop   tty input  for background process
  499. # SIG TTOU   22 22 27   Stop   tty output for background process
  500.  
  501.   export LWDFILE="$HOME/.lwd"
  502.  
  503.   lwdcd()
  504.   {
  505.  
  506.     local WD
  507.     local TTY=$(tty)
  508.  
  509.     [ "$1" != : ] \
  510.     && WD=$1 \
  511.     || {
  512.          [ -s "$LWDFILE" ] && WD=$(grep -w "$TTY" "$LWDFILE" | cut -f3)
  513.        }
  514.  
  515.     builtin cd "${WD:-$HOME}" \
  516.     && {
  517.          [ -s "$LWDFILE" ] \
  518.          && {
  519.               grep -wv "$TTY" "$LWDFILE" >| "$LWDFILE-$$"
  520.               mv "$LWDFILE-$$" "$LWDFILE"
  521.             }
  522.          [ "$(readlink -f "$PWD")" != "$(readlink -f "$HOME")" ] && echo -e "$TTY\t$(date +'%Y/%m/%d %a %H:%M:%S %Z')\t$PWD" >> "$LWDFILE"
  523.        }
  524.  
  525.   }
  526.  
  527.   alias  cd="lwdcd"
  528.   alias lwd="[ -s \"$LWDFILE\" ] && sort -t/ -k4 -n \"$LWDFILE\""
  529.  
  530. # cd $( [ -s $LWDFILE ] && grep "$TTY" $LWDFILE | cut -f2 && cat < $LWDFILE | $( grep -v "$TTY" >| $LWDFILE ) )
  531. # trap '[ $(readlink -f $PWD) != $(readlink -f $HOME) ] && echo -e "$TTY\t$PWD" >> $LWDFILE' 0 2 3 15
  532.  
  533. # cd $( [ -s $LWDFILE ] && grep "$TTY" $LWDFILE | cut -f2 && grep -v "$TTY" $LWDFILE >| $LWDFILE-$$ && mv $LWDFILE-$$ $LWDFILE )
  534. # trap "[ \$(readlink -f \$PWD) != \$(readlink -f $HOME) ] && echo -e \"$TTY\t\$PWD\" >> $LWDFILE" 0 HUP INT QUIT TERM
  535.  
  536.  
  537.  
  538. # [bash_completion]
  539.  
  540.   [ -f /etc/bash_completion ] && . /etc/bash_completion
  541.  
  542.   _compssh ()
  543.   {
  544.     cur=${COMP_WORDS[COMP_CWORD]};
  545.     COMPREPLY=($(compgen -W '$(cat ${HOME}/.ssh/config)' -- $cur))
  546.   }
  547.   complete -F _compssh ssh
  548.  
  549.  
  550.  
  551. }
  552.  
  553.  
  554.  
  555. # Funcoes ZZ
  556.   [ -f /usr/bin/funcoeszz ] && . /usr/bin/funcoeszz
  557.  
  558.  
  559.  
  560. if alias | grep -q lwd
  561. then
  562.   echo -e "\nLast Working Directories: "
  563.   lwd || echo "none."
  564.   echo
  565.   cd :
  566. fi
  567.  
  568. [ "$(readlink -f '$PWD')" = "$(readlink -f '$HOME')" ] && cd
  569.  
  570.  
  571.  
  572. # EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement